diff --git a/app/lib/app.ts b/app/lib/app.ts index b67cce41..e48ac638 100644 --- a/app/lib/app.ts +++ b/app/lib/app.ts @@ -58,7 +58,7 @@ export class Application { if (!this.hasWindows()) { await this.newWindow() } - this.windows[0].send(event, ...args) + this.windows.filter(w => !w.isDestroyed())[0].send(event, ...args) } enableTray () { diff --git a/app/lib/index.ts b/app/lib/index.ts index d479f630..d6632593 100644 --- a/app/lib/index.ts +++ b/app/lib/index.ts @@ -39,7 +39,6 @@ const argv = parseArgs(process.argv, process.cwd()) if (!app.requestSingleInstanceLock()) { app.quit() - process.exit(0) } if (argv.d) { diff --git a/app/lib/window.ts b/app/lib/window.ts index 8966e931..c7311c42 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -147,6 +147,10 @@ export class Window { this.window.webContents.send(event, ...args) } + isDestroyed() { + return !this.window || this.window.isDestroyed(); + } + private setupWindowManagement () { this.window.on('show', () => { this.visible.next(true) diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 05bf11c6..6765d72a 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -147,6 +147,8 @@ export class HostAppService { this.cliPaste.next(text) } else if (op === 'profile') { this.cliOpenProfile.next(argv.profileName) + } else if (op === undefined) { + this.newWindow(); } else { this.secondInstance.next() }