fix: harden application lifecycle and termination logic to prevent defunct processes and orphaned tray icons
This commit is contained in:
@@ -164,7 +164,12 @@ const updateTrayMenu = () => {
|
||||
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Show Dashboard', click: () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } } },
|
||||
{ label: 'Quit', click: () => { (app as any).isQuitting = true; app.quit(); } }
|
||||
{ label: 'Quit', click: () => {
|
||||
console.log('[Tray] Quit requested');
|
||||
(app as any).isQuitting = true;
|
||||
if (tray) tray.destroy();
|
||||
app.quit();
|
||||
} }
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
};
|
||||
@@ -466,9 +471,32 @@ app.whenReady().then(() => {
|
||||
steamClient.startWatching(handleLocalAccountsFound);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => { if (process.platform !== 'darwin' && (app as any).isQuitting) app.quit(); });
|
||||
// Support for background running
|
||||
(app as any).isQuitting = false;
|
||||
|
||||
app.on('before-quit', () => {
|
||||
console.log('[App] Preparing to quit...');
|
||||
(app as any).isQuitting = true;
|
||||
if (tray) {
|
||||
tray.destroy();
|
||||
tray = null;
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin' && (app as any).isQuitting) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); else mainWindow?.show(); });
|
||||
|
||||
// Handle terminal termination (Ctrl+C)
|
||||
process.on('SIGINT', () => {
|
||||
(app as any).isQuitting = true;
|
||||
app.quit();
|
||||
});
|
||||
|
||||
// --- IPC Handlers ---
|
||||
ipcMain.handle('get-accounts', () => store.get('accounts'));
|
||||
ipcMain.handle('get-server-config', () => store.get('serverConfig'));
|
||||
|
||||
Reference in New Issue
Block a user