From 92e157de3036e801e11f1e4b8a2faab5c48a55b4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 Sep 2013 18:32:05 +0800 Subject: [PATCH] Fix crash when using protocol module on startup. 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 | 5 +++++ spec/main.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/browser/atom_browser_main_parts.cc b/browser/atom_browser_main_parts.cc index 2ee9c08e..aaec24be 100644 --- a/browser/atom_browser_main_parts.cc +++ b/browser/atom_browser_main_parts.cc @@ -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(AtomBrowserContext::Get())-> + GetRequestContext(); + #if !defined(OS_MACOSX) // The corresponding call in OS X is in AtomApplicationDelegate. Browser::Get()->WillFinishLaunching(); diff --git a/spec/main.js b/spec/main.js index 0d021157..f2e52627 100644 --- a/spec/main.js +++ b/spec/main.js @@ -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, -- 2.43.0