Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Fix undefined icon causes crashes on macOS & Linux (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Jan 15, 2021
1 parent 6c7b79e commit 989dc36
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ if (!gotTheLock) {
defaultWidth: 400,
defaultHeight: 500,
});
mainWindow = new BrowserWindow({

const winOpts = {
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
Expand All @@ -251,17 +252,26 @@ if (!gotTheLock) {
autoHideMenuBar: false,
show: false,
frame: process.platform === 'darwin',
// manually set dock icon for AppImage
// Snap icon is set correct already so no need to intervene
icon: process.platform === 'linux' && process.env.SNAP == null ? path.resolve(__dirname, 'images', 'icon-linux.png') : undefined,
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false,
webSecurity: false,
preload: path.join(__dirname, 'preload', 'default.js'),
},
});
};

// manually set dock icon for AppImage
// Snap icon is set correct already so no need to intervene
const icon = process.platform === 'linux' && process.env.SNAP == null ? path.resolve(__dirname, 'images', 'icon-linux.png') : undefined;
// winOpts.icon cannot be set to undefined
// as it'd crash Electron on macOS
// https://github.com/electron/electron/issues/27303#issuecomment-759501184
if (icon) {
winOpts.icon = icon;
}

mainWindow = new BrowserWindow(winOpts);
mainWindowState.manage(mainWindow);

mainWindow.on('enter-full-screen', () => {
Expand Down

0 comments on commit 989dc36

Please sign in to comment.