fix: don't set delegate for QLPreviewPanel (#37530)

fix: don't set delegate for QLPreviewPanel
This commit is contained in:
Jeremy Spiegel 2023-03-14 06:41:34 -07:00 committed by GitHub
parent e480cb7103
commit bf1cc1aeb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -276,12 +276,10 @@ void SwizzleMouseDown(NSView* frame_view,
}
- (void)beginPreviewPanelControl:(QLPreviewPanel*)panel {
panel.delegate = [self delegate];
panel.dataSource = static_cast<id<QLPreviewPanelDataSource>>([self delegate]);
}
- (void)endPreviewPanelControl:(QLPreviewPanel*)panel {
panel.delegate = nil;
panel.dataSource = nil;
}

View file

@ -5275,6 +5275,22 @@ describe('BrowserWindow module', () => {
w.closeFilePreview();
}).to.not.throw();
});
it('should not call BrowserWindow show event', async () => {
const w = new BrowserWindow({ show: false });
const shown = once(w, 'show');
w.show();
await shown;
let showCalled = false;
w.on('show', () => {
showCalled = true;
});
w.previewFile(__filename);
await setTimeout(500);
expect(showCalled).to.equal(false, 'should not have called show twice');
});
});
// TODO (jkleinsc) renable these tests on mas arm64