Fix 'Image could not be created' app error on run (fix #992)

Electron 9.x now crashes when passed a non-existent icon.
Also, it accepts both ico and png.
So, do our best to pass it a file that exists.
This commit is contained in:
Ronan Jouchet 2020-07-18 01:26:23 -04:00
parent e592c6bca6
commit f23447312d
1 changed files with 13 additions and 1 deletions

View File

@ -63,7 +63,19 @@ export function debugLog(browserWindow: BrowserWindow, message: string): void {
}
export function getAppIcon(): string {
return path.join(__dirname, '..', `icon.${isWindows() ? 'ico' : 'png'}`);
// Prefer ICO under Windows, see
// https://www.electronjs.org/docs/api/browser-window#new-browserwindowoptions
// https://www.electronjs.org/docs/api/native-image#supported-formats
if (isWindows()) {
const ico = path.join(__dirname, '..', 'icon.ico');
if (fs.existsSync(ico)) {
return ico;
}
}
const png = path.join(__dirname, '..', 'icon.png');
if (fs.existsSync(png)) {
return png;
}
}
export function nativeTabsSupported(): boolean {