From eb5f5dcf4901506d56069450687c7a4f14c92c5e Mon Sep 17 00:00:00 2001 From: MuHong Byun Date: Wed, 6 Jan 2021 10:23:21 +0900 Subject: [PATCH] Clean-up channel view resource upon exiting app Signed-off-by: MuHong Byun --- .../tizen/channels/platform_view_channel.cc | 15 ++++++++------- .../tizen/channels/platform_view_channel.h | 1 + shell/platform/tizen/tizen_embedder_engine.cc | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 0cc283b185588..63b1947eb0f76 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -74,19 +74,20 @@ PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger) result) { HandleMethodCall(call, std::move(result)); }); } -PlatformViewChannel::~PlatformViewChannel() { - // Clean-up view_factories_ - for (auto const& [viewType, viewFactory] : view_factories_) { - viewFactory->Dispose(); - } - view_factories_.clear(); +PlatformViewChannel::~PlatformViewChannel() { Dispose(); } +void PlatformViewChannel::Dispose() { // Clean-up view_instances_ for (auto const& [viewId, viewInstance] : view_instances_) { - viewInstance->Dispose(); delete viewInstance; } view_instances_.clear(); + + // Clean-up view_factories_ + for (auto const& [viewType, viewFactory] : view_factories_) { + viewFactory->Dispose(); + } + view_factories_.clear(); } void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index d9fb4082d8ee9..19eb3db99e27d 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -19,6 +19,7 @@ class PlatformViewChannel { public: explicit PlatformViewChannel(flutter::BinaryMessenger* messenger); virtual ~PlatformViewChannel(); + void Dispose(); std::map>& ViewFactories() { return view_factories_; } diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index 3a517246b03ce..e97d58711be24 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -200,6 +200,9 @@ bool TizenEmbedderEngine::RunEngine( bool TizenEmbedderEngine::StopEngine() { if (flutter_engine) { + if (platform_view_channel) { + platform_view_channel->Dispose(); + } if (plugin_registrar_destruction_callback_) { plugin_registrar_destruction_callback_(plugin_registrar_.get()); }