From: Hwankyu Jhun Date: Thu, 4 Feb 2021 03:43:10 +0000 (+0900) Subject: Fix GMainContext creation X-Git-Tag: submit/tizen/20210204.091602~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c0b586376559f03d6679c80d9f937de93511d753;p=platform%2Fcore%2Fappfw%2Fcomponent-based-application.git Fix GMainContext creation To separate the context from the existed main context, the MainLoop class always creates the GMainContext. Change-Id: I1b4bd789c1cac7ca15a9db0e5eaf8d5e7974b551 Signed-off-by: Hwankyu Jhun --- diff --git a/component_based/port/main_loop.cc b/component_based/port/main_loop.cc index 7b373c9..0a465ad 100644 --- a/component_based/port/main_loop.cc +++ b/component_based/port/main_loop.cc @@ -22,12 +22,11 @@ namespace component_based { -MainLoop::MainLoop() = default; +MainLoop::MainLoop() { + context_ = g_main_context_new(); +} MainLoop::~MainLoop() { - if (thread_default_) - g_main_context_pop_thread_default(context_); - if (loop_) { if (g_main_loop_is_running(loop_)) g_main_loop_quit(loop_); @@ -40,22 +39,10 @@ MainLoop::~MainLoop() { } void MainLoop::Run() { - if (context_ == nullptr) { - if (gettid() != getpid()) { - _W("Sub thread"); - context_ = g_main_context_get_thread_default(); - if (context_ == nullptr) { - context_ = g_main_context_new(); - g_main_context_push_thread_default(context_); - thread_default_ = true; - } else { - context_ = g_main_context_ref_thread_default(); - } - } else { - _W("Main thread"); - context_ = g_main_context_ref(g_main_context_default()); - } - } + if (gettid() != getpid()) + _W("Sub thread"); + else + _W("Main thread"); if (loop_ == nullptr) loop_ = g_main_loop_new(context_, FALSE); diff --git a/component_based/port/main_loop.hh b/component_based/port/main_loop.hh index e475ca4..06060f3 100644 --- a/component_based/port/main_loop.hh +++ b/component_based/port/main_loop.hh @@ -32,7 +32,6 @@ class MainLoop { GMainContext* GetContext() const; private: - bool thread_default_ = false; GMainContext* context_ = nullptr; GMainLoop* loop_ = nullptr; };