Skip to content

Commit

Permalink
fix: don't set delegate for QLPreviewPanel (#37576)
Browse files Browse the repository at this point in the history
fix: don't set delegate for QLPreviewPanel

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Spiegel <jeremy.spiegel@frontapp.com>
  • Loading branch information
trop[bot] and jeremyspiegel committed Mar 16, 2023
1 parent a831d69 commit 24ce948
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 0 additions & 2 deletions shell/browser/ui/cocoa/electron_ns_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ - (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel*)panel {
}

- (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;
}

Expand Down
16 changes: 16 additions & 0 deletions spec/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5202,6 +5202,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 = emittedOnce(w, 'show');
w.show();
await shown;

let showCalled = false;
w.on('show', () => {
showCalled = true;
});

w.previewFile(__filename);
await delay(500);
expect(showCalled).to.equal(false, 'should not have called show twice');
});
});

// TODO (jkleinsc) renable these tests on mas arm64
Expand Down

0 comments on commit 24ce948

Please sign in to comment.