Skip to content

Commit

Permalink
Clean-up channel view resource upon exiting app (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: MuHong Byun <[email protected]>
  • Loading branch information
bwikbs authored Jan 7, 2021
1 parent ca52fc7 commit 7e89462
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 8 additions & 7 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PlatformViewChannel {
public:
explicit PlatformViewChannel(flutter::BinaryMessenger* messenger);
virtual ~PlatformViewChannel();
void Dispose();
std::map<std::string, std::unique_ptr<PlatformViewFactory>>& ViewFactories() {
return view_factories_;
}
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 7e89462

Please sign in to comment.