fix: win.closeFilePreview recreates panel when called twice (#45663)

* fix: close quick look during tests on macOS

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* use longer delay 🤷

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: sharedPreviewPanel being recreated on close

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* test: ensure preview panel gets closed

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
trop[bot]
2025-02-18 10:00:14 +01:00
committed by GitHub
parent eee1b523dd
commit 2e256e301d
2 changed files with 5 additions and 1 deletions

View File

@@ -1556,8 +1556,11 @@ void NativeWindowMac::PreviewFile(const std::string& path,
}
void NativeWindowMac::CloseFilePreview() {
if ([QLPreviewPanel sharedPreviewPanelExists]) {
// Need to be careful about checking [QLPreviewPanel sharedPreviewPanel] as
// simply accessing it will cause it to reinitialize and reappear.
if ([QLPreviewPanel sharedPreviewPanelExists] && preview_item_) {
[[QLPreviewPanel sharedPreviewPanel] close];
preview_item_ = nil;
}
}

View File

@@ -6223,6 +6223,7 @@ describe('BrowserWindow module', () => {
w.previewFile(__filename);
await setTimeout(500);
expect(showCalled).to.equal(false, 'should not have called show twice');
w.closeFilePreview();
});
});