]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix crash when calling app.quit() before app is ready
authorCheng Zhao <zcbenz@gmail.com>
Thu, 22 Oct 2015 08:06:37 +0000 (16:06 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 22 Oct 2015 08:06:37 +0000 (16:06 +0800)
atom/browser/browser.cc

index d8bb94103cd9dc4ca55690b66dcaf45d610c693d..79ebe91a87e65d3514add4dd2484e2473b0ce795 100644 (file)
@@ -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 {