From bba33cd10303da4fa8931cafb63e43b176d6ba74 Mon Sep 17 00:00:00 2001 From: pa Date: Tue, 31 Mar 2026 13:58:30 +0900 Subject: [PATCH] fix: Cannot access 'tray' before initialization --- src-electron/main.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src-electron/main.js b/src-electron/main.js index a73d567a..a363a48e 100644 --- a/src-electron/main.js +++ b/src-electron/main.js @@ -49,6 +49,10 @@ let isOverlayActive = false; let appIsQuitting = false; const rootDir = app.getAppPath(); +let tray = null; +let trayIcon = null; +let trayIconNotify = null; + // Get launch arguments let appImagePath = process.env.APPIMAGE; const args = process.argv.slice(1); @@ -477,9 +481,7 @@ function writeOverlayFrame(imageBuffer) { } } -let tray = null; -let trayIcon = null; -let trayIconNotify = null; + function destroyTray() { if (tray) { tray.destroy(); @@ -545,7 +547,9 @@ function createTray() { } function setTrayIconNotification(notify) { - tray.setImage(notify ? trayIconNotify : trayIcon); + if (tray) { + tray.setImage(notify ? trayIconNotify : trayIcon); + } } async function installVRCX() {