From: Hwankyu Jhun Date: Wed, 11 Sep 2019 06:19:56 +0000 (+0900) Subject: Fix termination logic X-Git-Tag: submit/tizen/20190916.231130~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c96ce6c85f7f8b34bebb9e5f47c152c158f4c340;p=platform%2Fcore%2Fappfw%2Fcomponent-based-application.git Fix termination logic Change-Id: If45818dab519818e33a6ae83c84f943b67e21d20 Signed-off-by: Hwankyu Jhun --- diff --git a/component_based/base/application_base.cc b/component_based/base/application_base.cc index 576cdc7..877c389 100644 --- a/component_based/base/application_base.cc +++ b/component_based/base/application_base.cc @@ -60,6 +60,12 @@ void ApplicationBase::Impl::OnBaseRun() { void ApplicationBase::Impl::OnBaseExit() { LOGD(""); + if (exiting_) { + LOGD("Already exiting"); + return; + } + + exiting_ = true; parent_->OnExit(); } diff --git a/component_based/base/application_base_implementation.h b/component_based/base/application_base_implementation.h index aef1c8d..5821cf8 100644 --- a/component_based/base/application_base_implementation.h +++ b/component_based/base/application_base_implementation.h @@ -58,6 +58,7 @@ class ApplicationBase::Impl : internal::CoreBase::IEventListener { ApplicationBase* parent_; std::unique_ptr core_base_; std::string app_id_; + bool exiting_ = false; }; } // namespace component_based diff --git a/component_based/base/component.cc b/component_based/base/component.cc index cec29a8..29656fc 100644 --- a/component_based/base/component.cc +++ b/component_based/base/component.cc @@ -311,7 +311,7 @@ std::string Component::GetInstanceID() { void Component::Finish() { auto& mgr = internal::ComponentManager::GetInst(); - mgr.Exit(impl_->GetInstanceID()); + mgr.ExitAtIdle(impl_->GetInstanceID()); } Component::Type Component::GetType() { diff --git a/component_based/base/component_manager_internal.cc b/component_based/base/component_manager_internal.cc index 8bb18c1..c4e1065 100644 --- a/component_based/base/component_manager_internal.cc +++ b/component_based/base/component_manager_internal.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -143,6 +144,15 @@ void ComponentManager::Exit(const std::string& inst_id) { appcore_multiwindow_base_instance_exit(context); } +void ComponentManager::ExitAtIdle(const std::string& inst_id) { + g_idle_add([](gpointer data) -> gboolean { + char* inst_id = static_cast(data); + ComponentManager::GetInst().Exit(inst_id); + free(inst_id); + return G_SOURCE_REMOVE; + }, strdup(inst_id.c_str())); +} + void ComponentManager::ExitAll() { if (inst_map_.empty()) return; @@ -315,6 +325,11 @@ void ComponentManager::OnTerminateCB( ev->OnStop(); ev->OnDestroy(); mgr.Remove(inst_id); + + if (appcore_multiwindow_base_instance_get_cnt() == 1) { + LOGD("Exit"); + appcore_multiwindow_base_exit(); + } } void ComponentManager::OnPauseCB(appcore_multiwindow_base_instance_h context, diff --git a/component_based/base/component_manager_internal.h b/component_based/base/component_manager_internal.h index 3fec0a0..7dbb12b 100644 --- a/component_based/base/component_manager_internal.h +++ b/component_based/base/component_manager_internal.h @@ -63,6 +63,7 @@ class ComponentManager { void Stop(const std::string& inst_id); void Exit(const std::string& inst_id); + void ExitAtIdle(const std::string& inst_id); void ExitAll(); bool Bind(const std::string& inst_id, std::unique_ptr win); void Unbind(const std::string& inst_id);