Emit process exit event with app exit code
This commit is contained in:
		
					parent
					
						
							
								d2e63dfc64
							
						
					
				
			
			
				commit
				
					
						63c0095efb
					
				
			
		
					 3 changed files with 13 additions and 7 deletions
				
			
		|  | @ -344,7 +344,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( | ||||||
|   auto browser = base::Unretained(Browser::Get()); |   auto browser = base::Unretained(Browser::Get()); | ||||||
|   return mate::ObjectTemplateBuilder(isolate) |   return mate::ObjectTemplateBuilder(isolate) | ||||||
|       .SetMethod("quit", base::Bind(&Browser::Quit, browser)) |       .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("focus", base::Bind(&Browser::Focus, browser)) | ||||||
|       .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser)) |       .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser)) | ||||||
|       .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser)) |       .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser)) | ||||||
|  |  | ||||||
|  | @ -34,6 +34,18 @@ app.setAppPath = (path) -> | ||||||
| app.getAppPath = -> | app.getAppPath = -> | ||||||
|   appPath |   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. | # Routes the events to webContents. | ||||||
| for name in ['login', 'certificate-error', 'select-client-certificate'] | for name in ['login', 'certificate-error', 'select-client-certificate'] | ||||||
|   do (name) -> |   do (name) -> | ||||||
|  |  | ||||||
|  | @ -51,13 +51,7 @@ process.on 'uncaughtException', (error) -> | ||||||
|   message = "Uncaught Exception:\n#{stack}" |   message = "Uncaught Exception:\n#{stack}" | ||||||
|   dialog.showErrorBox 'A JavaScript error occurred in the main process', message |   dialog.showErrorBox 'A JavaScript error occurred in the main process', message | ||||||
| 
 | 
 | ||||||
| # Emit 'exit' event on quit. |  | ||||||
| {app} = require 'electron' | {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. | # Load the RPC server. | ||||||
| require './rpc-server' | require './rpc-server' | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kevin Sawicki
				Kevin Sawicki