From 4169bcf9026e139b1a5547877012290450621569 Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 20 Apr 2017 00:06:23 +0900 Subject: [PATCH] avoid crash problem at preventing 'new-window' event (#1) https://github.com/electron/electron/issues/9230 --- main/common.ts | 1 + main/window.ts | 9 ++++++--- package.json | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/main/common.ts b/main/common.ts index a5966ef..dba4e3d 100644 --- a/main/common.ts +++ b/main/common.ts @@ -4,6 +4,7 @@ import {app} from 'electron'; export const IS_DEBUG = process.env.NODE_ENV === 'development'; export const IS_DARWIN = process.platform === 'darwin'; export const IS_WINDOWS = process.platform === 'win32'; +export const IS_LINUX = process.platform === 'linux'; export const APP_ICON = path.join(__dirname, '..', 'resources', 'icon', 'icon.png'); export const PRELOAD_JS = path.join(__dirname, '..', 'renderer', 'preload.js'); export const DATA_DIR = app.getPath('userData'); diff --git a/main/window.ts b/main/window.ts index 6e7d924..e732fe9 100644 --- a/main/window.ts +++ b/main/window.ts @@ -4,7 +4,9 @@ import * as menubar from 'menubar'; import {Config, Account} from './config'; import {partitionForAccount} from './account_switcher'; import log from './log'; -import {IS_DEBUG, IS_DARWIN, IS_WINDOWS, APP_ICON, PRELOAD_JS, trayIcon} from './common'; +import {IS_DEBUG, IS_DARWIN, IS_WINDOWS, IS_LINUX, APP_ICON, PRELOAD_JS, trayIcon} from './common'; + +const ELECTRON_ISSUE_9230 = IS_WINDOWS || IS_LINUX; export default class Window { static create(account: Account, config: Config, mb: Menubar.MenubarApp | null = null) { @@ -34,9 +36,10 @@ export default class Window { log.debug('Opened URL with external browser (will-navigate)', url); }); browser.webContents.on('new-window', (e, url) => { - if (IS_WINDOWS) { + if (ELECTRON_ISSUE_9230) { // XXX: - // On Windows, rel="noopener" lets app crash on preventing the event. + // On Windows or Linux, rel="noopener" lets app crash on preventing the event. + // Issue: https://github.com/electron/electron/issues/9230 return; } e.preventDefault(); diff --git a/package.json b/package.json index 6246e35..303c24c 100644 --- a/package.json +++ b/package.json @@ -37,12 +37,12 @@ }, "homepage": "https://github.com/rhysd/Mstdn#readme", "devDependencies": { - "@types/electron": "^1.4.35", + "@types/electron": "^1.4.37", "@types/electron-window-state": "^2.0.28", "@types/loglevel": "^1.4.29", "@types/menubar": "^5.1.3", "@types/mousetrap": "^1.5.33", - "@types/node": "^7.0.12", + "@types/node": "^7.0.13", "browserify": "^14.3.0", "electron-packager": "^8.6.0", "npm-run-all": "^4.0.2", @@ -50,7 +50,7 @@ "typescript": "^2.2.2" }, "dependencies": { - "electron": "^1.6.2", + "electron": "^1.6.5", "electron-window-state": "^4.1.1", "loglevel": "^1.4.1", "menubar": "github:rhysd/menubar#mstdn",