diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index b16e3460650f..96f1ce025372 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -271,15 +271,15 @@ v8::Local App::DefaultSession(v8::Isolate* isolate) { bool App::MakeSingleInstance(v8::Local callback) { auto browser = Browser::Get(); - single_instance_callback_ = callback; + if (browser->InitializeSingleInstance()) { + single_instance_callback_ = callback; - browser->InitializeSingleInstance(); + ProcessSingleton::NotificationCallback cb; + mate::Converter::FromV8( + isolate(), single_instance_callback_, &cb); - ProcessSingleton::NotificationCallback cb; - mate::Converter::FromV8( - isolate(), single_instance_callback_, &cb); - - browser->SetSingleInstanceCallback(cb); + browser->SetSingleInstanceCallback(cb); + } switch (browser->GetSingleInstanceResult()) { case ProcessSingleton::NotifyResult::PROCESS_NONE: diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index c8d6104beae4..6bfeae3c56b1 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -165,7 +165,7 @@ bool Browser::HandleBeforeQuit() { return !prevent_default; } -void Browser::InitializeSingleInstance() { +bool Browser::InitializeSingleInstance() { base::FilePath userDir; PathService::Get(brightray::DIR_USER_DATA, &userDir); @@ -174,11 +174,12 @@ void Browser::InitializeSingleInstance() { userDir, base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this))); - process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); - if (is_ready_) { process_singleton_->Unlock(); } + + process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); + return true; } ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() { diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 1ac4d03e095a..f9b86b6924a0 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -66,7 +66,7 @@ class Browser : public WindowListObserver { // Clear the recent documents list. void ClearRecentDocuments(); - void InitializeSingleInstance(); + bool InitializeSingleInstance(); ProcessSingleton::NotifyResult GetSingleInstanceResult(); void SetSingleInstanceCallback( ProcessSingleton::NotificationCallback callback);