fix: add isDestroyed guard in setApplicationMenu and TODO for getWindow fallback

Add isDestroyed() check in the setApplicationMenu interceptor to skip
destroyed windows when hiding menu bars, matching the defensive pattern
used elsewhere in the codebase.

Add TODO comment on getWindow() popup fallback limitation to flag that
callers like getIsMaximized() may behave unexpectedly when a popup is
returned instead of the main window.

Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
aaddrick
2026-02-16 11:38:04 -05:00
parent 75841f0813
commit 0fc8286943
2 changed files with 3 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ function getWindow() {
const { BrowserWindow } = require('electron');
const focused = BrowserWindow.getFocusedWindow();
if (focused) return focused;
// TODO: Fallback may return a popup window; callers like
// getIsMaximized() may behave unexpectedly on popups.
const win = BrowserWindow.getAllWindows().find(
(w) => !w.isDestroyed()
);

View File

@@ -139,6 +139,7 @@ Module.prototype.require = function(id) {
if (process.platform === 'linux') {
// Hide menu bar on all existing windows after menu is set
for (const win of module.BrowserWindow.getAllWindows()) {
if (win.isDestroyed()) continue;
win.setMenuBarVisibility(false);
}
console.log('[Frame Fix] Menu bar hidden on all windows');