]> khamidou — GitHub mirrors - electron.git/commitdiff
Make sure current task runner is available
authorCheng Zhao <zcbenz@gmail.com>
Thu, 22 Oct 2015 06:56:57 +0000 (14:56 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 22 Oct 2015 06:56:57 +0000 (14:56 +0800)
When calling makeSingleInstance we have to ensure current task runnder
is available, otherwise crash may happen.

atom/browser/atom_browser_main_parts.cc

index 4c11176997caec899610044e1c63e02f6cc59b54..dfbdf4477fbaeea682f7b3489035b46f9ea22573 100644 (file)
@@ -62,17 +62,15 @@ void AtomBrowserMainParts::PreEarlyInitialization() {
 void AtomBrowserMainParts::PostEarlyInitialization() {
   brightray::BrowserMainParts::PostEarlyInitialization();
 
-  {
-    // Temporary set the bridge_task_runner_ as current thread's task runner,
-    // so we can fool gin::PerIsolateData to use it as its task runner, instead
-    // of getting current message loop's task runner, which is null for now.
-    bridge_task_runner_ = new BridgeTaskRunner;
-    base::ThreadTaskRunnerHandle handle(bridge_task_runner_);
-
-    // The ProxyResolverV8 has setup a complete V8 environment, in order to
-    // avoid conflicts we only initialize our V8 environment after that.
-    js_env_.reset(new JavascriptEnvironment);
-  }
+  // Temporary set the bridge_task_runner_ as current thread's task runner,
+  // so we can fool gin::PerIsolateData to use it as its task runner, instead
+  // of getting current message loop's task runner, which is null for now.
+  bridge_task_runner_ = new BridgeTaskRunner;
+  base::ThreadTaskRunnerHandle handle(bridge_task_runner_);
+
+  // The ProxyResolverV8 has setup a complete V8 environment, in order to
+  // avoid conflicts we only initialize our V8 environment after that.
+  js_env_.reset(new JavascriptEnvironment);
 
   node_bindings_->Initialize();