]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix crash when using protocol module on startup.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 20 Sep 2013 10:32:05 +0000 (18:32 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 20 Sep 2013 10:32:05 +0000 (18:32 +0800)
The job factory was not created before any request was sent, so when the
app used the protocol module on startup it would cause a crash.

browser/atom_browser_main_parts.cc
spec/main.js

index 2ee9c08e4e62d5d9248408640809b3fc6dae7d80..aaec24bea750144b674aa0c69484b35c0a5fccdd 100644 (file)
@@ -75,6 +75,11 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
 
   node_bindings_->RunMessageLoop();
 
+  // Make sure the url request job factory is created before the
+  // will-finish-launching event.
+  static_cast<content::BrowserContext*>(AtomBrowserContext::Get())->
+      GetRequestContext();
+
 #if !defined(OS_MACOSX)
   // The corresponding call in OS X is in AtomApplicationDelegate.
   Browser::Get()->WillFinishLaunching();
index 0d021157151efd0a0b6b838ee5de367c9ffbeed1..f2e52627946a49903ec39bc381fe4ea6cbb868e2 100644 (file)
@@ -35,6 +35,9 @@ app.on('window-all-closed', function() {
 });
 
 app.on('finish-launching', function() {
+  // Test if using protocol module would crash.
+  require('protocol').registerProtocol('test-if-crashes', function() {});
+
   window = new BrowserWindow({
     title: 'atom-shell tests',
     show: false,