fixup! Initial implementation of watch app 65/184965/2
authorSoorya R <soorya.r@samsung.com>
Tue, 24 Jul 2018 14:43:06 +0000 (20:13 +0530)
committerjaekuk lee <juku1999@samsung.com>
Wed, 25 Jul 2018 00:22:51 +0000 (00:22 +0000)
This CL fixes the crash that occurs when MakeRuntime
is called during prelaunch phase.

Change-Id: I685a0ea66fbdf21081a583781095755cd15ac799
Signed-off-by: Soorya R <soorya.r@samsung.com>
atom/app/runtime.cc
atom/app/runtime.h
atom/app/ui_runtime.cc
atom/app/watch_runtime.cc
tizen/src/wrt_main.cc

index fcfda5ee47d77fc696573832790e0677eb9ff2ed..c0894362234d848a2760f367a0610adaacfc4066 100644 (file)
@@ -17,6 +17,7 @@
 #include "atom/app/runtime.h"
 #include "atom/app/ui_runtime.h"
 #include "atom/app/watch_runtime.h"
+#include "atom/browser/atom_browser_main_parts.h"
 #include "atom/browser/native_window_efl.h"
 #include "base/logging.h"
 #include "efl/window_factory.h"
 
 namespace runtime {
 
+Runtime::Runtime() {
+  atom::AtomBrowserMainParts::SetNodeEnvironment();
+}
+
 Runtime::~Runtime() {
 }
 
index a5bcbc2459d566206a0f8784e6b9d1a0dd6a22df..c5552fb9459e2b8ed27b2ee6d1adc480c540fb9a 100644 (file)
@@ -27,6 +27,7 @@ namespace runtime {
 
 class Runtime {
  public:
+  Runtime();
   virtual ~Runtime() = 0;
 
   virtual int Exec() = 0;
index b38b7edd1846ba2ac8091faa7c804d6a97299259..c078f6513f3704865e6e4f1aecc8b96cdc1bc128 100644 (file)
 
 #include "atom/app/atom_main_delegate.h"
 #include "atom/app/ui_runtime.h"
-#include "atom/browser/browser.h"
 #include "atom/browser/atom_browser_client.h"
 #include "atom/browser/atom_browser_main_parts.h"
+#include "atom/browser/browser.h"
 #include "atom/common/atom_command_line.h"
 #include "base/logging.h"
 #include "content/public/app/content_main.h"
-#include "tizen/common/app_db.h"
+#include "gin/v8_initializer.h"
 #include "tizen/common/app_control.h"
-#include "tizen/common/constants.h"
+#include "tizen/common/app_db.h"
 #include "tizen/common/application_data.h"
 #include "tizen/common/command_line.h"
-
-#include "gin/v8_initializer.h"
+#include "tizen/common/constants.h"
 
 namespace runtime {
 
-UiRuntime::UiRuntime(content::ContentMainParams *params) {
-  _params = params;
-
-  // This line's position is essential as this creates the Browser
-  // object which is needed later on by ui_runtime in its ui_loop callbacks
-  atom::AtomBrowserMainParts::SetNodeEnvironment();
+UiRuntime::UiRuntime(content::ContentMainParams *params)
+    : _params(params) {
 }
 
 UiRuntime::~UiRuntime() {
index 1309b53dc41fe9075c04e7cc83192b0f074e7e0d..58b42040f5625d84c0ff00ce8edf169c7d637467 100644 (file)
@@ -38,9 +38,6 @@ namespace runtime {
 
 WatchRuntime::WatchRuntime(content::ContentMainParams *params)
     : _params(params) {
-  // This line's position is essential as this creates the Browser
-  // object which is needed later on by watch_runtime in its watch_loop callbacks
-  atom::AtomBrowserMainParts::SetNodeEnvironment();
 }
 
 WatchRuntime::~WatchRuntime() {
index 35027bd0a71bf652c48c01cf24b386c561fa9155..c32c28772646526e7324eb0b23d375bb8ecc4f81 100644 (file)
@@ -10,6 +10,7 @@
 #include "content/public/app/content_main.h"
 
 #include "atom/app/node_main.h"
+#include "atom/browser/atom_browser_main_parts.h"
 #include "atom/common/atom_command_line.h"
 #include "base/at_exit.h"
 #include "base/i18n/icu_util.h"
@@ -73,7 +74,6 @@ REFERENCE_MODULE(wrt);
 
 #if defined(OS_TIZEN)
 bool g_initialized_ = false;
-std::unique_ptr<runtime::Runtime> runtime_;
 
 // For debug purpose only.
 // TODO: To be removed later
@@ -106,6 +106,7 @@ int main(int argc, char* argv[]) {
     base::CommandLine::Init(argc, argv);
   }
 
+  std::unique_ptr<runtime::Runtime> runtime_;
   common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
   std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt");
 
@@ -144,9 +145,8 @@ int main(int argc, char* argv[]) {
 #if defined(OS_TIZEN)
   if (hasTizenPackageID(argc,argv)) { // TODO: Check to be removed later
     elm_init(argc, argv);
-    if (!g_initialized_) {
-      runtime_ = runtime::Runtime::MakeRuntime(&params);
-    } else {
+    runtime_ = runtime::Runtime::MakeRuntime(&params);
+    if (g_initialized_) {
       runtime_->SetParam(&params);
     }
     return runtime_->Exec();
@@ -172,7 +172,7 @@ int main(int argc, const char* argv[]) {
       params.argc = argc;
       params.argv = const_cast<const char**>(argv);
       atom::AtomCommandLine::Init(argc, argv);
-      runtime_ = runtime::Runtime::MakeRuntime(nullptr);
+      atom::AtomBrowserMainParts::SetNodeEnvironment();
       tizen::PreloadManager::GetInstance()->CreateCacheComponent();
       return 0;
     };