Skip to content

Commit

Permalink
fix: object has been destroyed
Browse files Browse the repository at this point in the history
receive an error from webContents saying the object has been destroyed when executing the line
win.webContents.off('destroyed', disposable);

we can't unsubscribe once it's already destroyed
  • Loading branch information
benoitf committed Aug 27, 2024
1 parent 125230e commit 044fb00
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,11 @@ export default function contextMenu(options = {}) {
const disposeMenu = create(win, options);

const disposable = () => {
win.webContents.off('destroyed', disposable);
disposeMenu();
};

win.webContents.off('destroyed', disposable);

if (win.once !== undefined) { // Support for BrowserView
win.webContents.once('destroyed', disposable);
}
Expand Down

0 comments on commit 044fb00

Please sign in to comment.