Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Commit

Permalink
Unregister per-window hotkeys when window is closed.
Browse files Browse the repository at this point in the history
Without this, the sequence +n, +W, +W crashes because a handler is
called with the deleted window.

I don't think this can be effectively tested.
  • Loading branch information
ncalexan committed May 25, 2016
1 parent 57dec82 commit b94c5b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/main/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ async function makeBrowserWindow(): Promise<electron.BrowserWindow> {
browser.loadURL(fileUrl(path.join(UI_DIR, 'browser', 'browser.html')));

hotkeys.bindBrowserWindowHotkeys(browser);
browser.once('closed', () => {
hotkeys.unbindBrowserWindowHotkeys(browser);
});

return browser;
}
Expand Down
4 changes: 4 additions & 0 deletions app/main/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function bindBrowserWindowHotkeys(browserWindow) {
});
}

export function unbindBrowserWindowHotkeys(browserWindow) {
shortcut.unregisterAll(browserWindow);
}

/**
* To be used in responding to IPC 'synthesize-accelerator' messages, by looking
* through hotkeys defined and firing the message to the active browser window if found.
Expand Down

0 comments on commit b94c5b1

Please sign in to comment.