fix: keep strong reference to tray icon to prevent GC on Linux
This commit is contained in:
parent
13bd7e1522
commit
d91dc1d5e2
1 changed files with 5 additions and 2 deletions
|
|
@ -10,6 +10,8 @@ import { getThemeFiles, getActiveTheme, applyTheme, cycleTheme, reloadTheme, ope
|
||||||
|
|
||||||
// internal tray state
|
// internal tray state
|
||||||
let tray: Tray = null;
|
let tray: Tray = null;
|
||||||
|
// Keep strong reference to prevent garbage collection on Linux
|
||||||
|
let trayIcon: Electron.NativeImage;
|
||||||
|
|
||||||
// Create and resize tray icon for macOS
|
// Create and resize tray icon for macOS
|
||||||
function createTrayIcon() {
|
function createTrayIcon() {
|
||||||
|
|
@ -17,10 +19,11 @@ function createTrayIcon() {
|
||||||
const image = nativeImage.createFromDataURL(macOsTrayIconAsset);
|
const image = nativeImage.createFromDataURL(macOsTrayIconAsset);
|
||||||
const resized = image.resize({ width: 20, height: 20 });
|
const resized = image.resize({ width: 20, height: 20 });
|
||||||
resized.setTemplateImage(true);
|
resized.setTemplateImage(true);
|
||||||
return resized;
|
trayIcon = resized;
|
||||||
} else {
|
} else {
|
||||||
return nativeImage.createFromDataURL(trayIconAsset);
|
trayIcon = nativeImage.createFromDataURL(trayIconAsset);
|
||||||
}
|
}
|
||||||
|
return trayIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initTray() {
|
export function initTray() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue