From: Cheng Zhao Date: Thu, 22 Oct 2015 08:06:37 +0000 (+0800) Subject: Fix crash when calling app.quit() before app is ready X-Git-Tag: v0.34.1~7^2~8 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ca876e424bd71de5fe09d6efb56e79482cfffed9;p=electron.git Fix crash when calling app.quit() before app is ready --- diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index d8bb9410..79ebe91a 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -53,8 +53,14 @@ void Browser::Shutdown() { is_quiting_ = true; FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); - base::MessageLoop::current()->PostTask( - FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); + + if (base::MessageLoop::current()) { + base::MessageLoop::current()->PostTask( + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); + } else { + // There is no message loop available so we are in early stage. + exit(0); + } } std::string Browser::GetVersion() const {