mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Emit process exit event with app exit code
This commit is contained in:
@@ -344,7 +344,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
return mate::ObjectTemplateBuilder(isolate)
|
||||
.SetMethod("quit", base::Bind(&Browser::Quit, browser))
|
||||
.SetMethod("exit", base::Bind(&Browser::Exit, browser))
|
||||
.SetMethod("_exit", base::Bind(&Browser::Exit, browser))
|
||||
.SetMethod("focus", base::Bind(&Browser::Focus, browser))
|
||||
.SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser))
|
||||
.SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser))
|
||||
|
||||
@@ -34,6 +34,18 @@ app.setAppPath = (path) ->
|
||||
app.getAppPath = ->
|
||||
appPath
|
||||
|
||||
appExitCode = undefined
|
||||
app.exit = (exitCode) ->
|
||||
appExitCode = exitCode
|
||||
app._exit(exitCode)
|
||||
|
||||
# Map process.exit to app.exit, which quits gracefully.
|
||||
process.exit = app.exit
|
||||
|
||||
# Emit a process 'exit' event on app quit.
|
||||
app.on 'quit', ->
|
||||
process.emit 'exit', appExitCode
|
||||
|
||||
# Routes the events to webContents.
|
||||
for name in ['login', 'certificate-error', 'select-client-certificate']
|
||||
do (name) ->
|
||||
|
||||
@@ -51,13 +51,7 @@ process.on 'uncaughtException', (error) ->
|
||||
message = "Uncaught Exception:\n#{stack}"
|
||||
dialog.showErrorBox 'A JavaScript error occurred in the main process', message
|
||||
|
||||
# Emit 'exit' event on quit.
|
||||
{app} = require 'electron'
|
||||
app.on 'quit', ->
|
||||
process.emit 'exit'
|
||||
|
||||
# Map process.exit to app.exit, which quits gracefully.
|
||||
process.exit = app.exit
|
||||
|
||||
# Load the RPC server.
|
||||
require './rpc-server'
|
||||
|
||||
Reference in New Issue
Block a user