mirror of
https://github.com/plebbit/seedit.git
synced 2026-05-19 22:27:35 -04:00
fix(electron): keep module-scoped Tray ref and destroy before reassign
This commit is contained in:
@@ -38,6 +38,9 @@ if (isLinux && !process.env.SEEDIT_NO_ENV_SANITIZE) {
|
||||
delete process.env.LD_PRELOAD;
|
||||
}
|
||||
|
||||
// Keep a global Tray reference to prevent GC removing the tray icon
|
||||
let tray;
|
||||
|
||||
// Determine __filename and dirname for ESM
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const dirname = path.dirname(__filename);
|
||||
@@ -346,7 +349,12 @@ const createMainWindow = () => {
|
||||
if (!trayDisabled) {
|
||||
// tray
|
||||
const trayIconPath = path.join(dirname, '..', isDev ? 'public' : 'build', 'electron-tray-icon.png');
|
||||
const tray = new Tray(trayIconPath);
|
||||
if (tray) {
|
||||
try {
|
||||
tray.destroy();
|
||||
} catch (e) {}
|
||||
}
|
||||
tray = new Tray(trayIconPath);
|
||||
tray.setToolTip('seedit');
|
||||
const trayMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user