From adf9acc468a303c3addb7edf11eed5edf0d2438b Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 30 Aug 2016 13:30:56 +1000 Subject: [PATCH] Default app exit code to 0 --- atom/browser/browser.cc | 5 ++++- atom/browser/browser.h | 2 +- docs/api/app.md | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index dd958d0dc7d2..6c3edc0d6e3d 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -48,7 +48,10 @@ void Browser::Quit() { window_list->CloseAllWindows(); } -void Browser::Exit(int code) { +void Browser::Exit(mate::Arguments* args) { + int code = 0; + args->GetNext(&code); + if (!AtomBrowserMainParts::Get()->SetExitCode(code)) { // Message loop is not ready, quit directly. exit(code); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 9fb8afe32ec3..924685510f7e 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -46,7 +46,7 @@ class Browser : public WindowListObserver { void Quit(); // Exit the application immediately and set exit code. - void Exit(int code); + void Exit(mate::Arguments* args); // Cleanup everything and shutdown the application gracefully. void Shutdown(); diff --git a/docs/api/app.md b/docs/api/app.md index aad9809d3723..aeb003d33974 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -305,11 +305,11 @@ This method guarantees that all `beforeunload` and `unload` event handlers are correctly executed. It is possible that a window cancels the quitting by returning `false` in the `beforeunload` event handler. -### `app.exit(exitCode)` +### `app.exit([exitCode])` -* `exitCode` Integer +* `exitCode` Integer (optional) -Exits immediately with `exitCode`. +Exits immediately with `exitCode`. `exitCode` defaults to 0. All windows will be closed immediately without asking user and the `before-quit` and `will-quit` events will not be emitted.