Merge pull request #4968 from phamdaniel/exit-events
Don't emit 'will-quit' when 'app.exit()' is called.
This commit is contained in:
commit
efb0fc2ea5
2 changed files with 12 additions and 3 deletions
|
@ -15,6 +15,7 @@ namespace atom {
|
|||
|
||||
Browser::Browser()
|
||||
: is_quiting_(false),
|
||||
is_exiting_(false),
|
||||
is_ready_(false),
|
||||
is_shutdown_(false) {
|
||||
WindowList::AddObserver(this);
|
||||
|
@ -49,9 +50,12 @@ void Browser::Exit(int code) {
|
|||
// Message loop is not ready, quit directly.
|
||||
exit(code);
|
||||
} else {
|
||||
// Prepare to quit when all windows have been closed..
|
||||
// Prepare to quit when all windows have been closed.
|
||||
is_quiting_ = true;
|
||||
|
||||
// Remember this caller so that we don't emit unrelated events.
|
||||
is_exiting_ = true;
|
||||
|
||||
// Must destroy windows before quitting, otherwise bad things can happen.
|
||||
atom::WindowList* window_list = atom::WindowList::GetInstance();
|
||||
if (window_list->size() == 0) {
|
||||
|
@ -175,7 +179,9 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) {
|
|||
}
|
||||
|
||||
void Browser::OnWindowAllClosed() {
|
||||
if (is_quiting_)
|
||||
if (is_exiting_)
|
||||
Shutdown();
|
||||
else if (is_quiting_)
|
||||
NotifyAndShutdown();
|
||||
else
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed());
|
||||
|
|
|
@ -189,10 +189,13 @@ class Browser : public WindowListObserver {
|
|||
// Observers of the browser.
|
||||
base::ObserverList<BrowserObserver> observers_;
|
||||
|
||||
// Whether `app.exit()` has been called
|
||||
bool is_exiting_;
|
||||
|
||||
// Whether "ready" event has been emitted.
|
||||
bool is_ready_;
|
||||
|
||||
// The browse is being shutdown.
|
||||
// The browser is being shutdown.
|
||||
bool is_shutdown_;
|
||||
|
||||
std::string version_override_;
|
||||
|
|
Loading…
Reference in a new issue