fix: close all open sheets before closing window on macOS (#43706)

This commit is contained in:
John Beutner 2024-09-25 07:23:49 -04:00 коммит произвёл GitHub
Родитель 1d3b1284c4
Коммит c8895d0547
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -352,8 +352,11 @@ void NativeWindowMac::Close() {
// [window_ performClose:nil], the window won't close properly // [window_ performClose:nil], the window won't close properly
// even after the user has ended the sheet. // even after the user has ended the sheet.
// Ensure it's closed before calling [window_ performClose:nil]. // Ensure it's closed before calling [window_ performClose:nil].
if ([window_ attachedSheet]) // If multiple sheets are open, they must all be closed.
while ([window_ attachedSheet]) {
[window_ endSheet:[window_ attachedSheet]]; [window_ endSheet:[window_ attachedSheet]];
}
DCHECK_EQ([[window_ sheets] count], 0UL);
// window_ could be nil after performClose. // window_ could be nil after performClose.
bool should_notify = is_modal() && parent() && IsVisible(); bool should_notify = is_modal() && parent() && IsVisible();

Просмотреть файл

@ -117,6 +117,14 @@ describe('BrowserWindow module', () => {
await closed; await closed;
}); });
it('should work if called when multiple messageBoxes are showing', async () => {
const closed = once(w, 'closed');
dialog.showMessageBox(w, { message: 'Hello Error' });
dialog.showMessageBox(w, { message: 'Hello Error' });
w.close();
await closed;
});
it('closes window without rounded corners', async () => { it('closes window without rounded corners', async () => {
await closeWindow(w); await closeWindow(w);
w = new BrowserWindow({ show: false, frame: false, roundedCorners: false }); w = new BrowserWindow({ show: false, frame: false, roundedCorners: false });