diff --git a/flutter/shell/platform/tizen/channels/platform_channel.cc b/flutter/shell/platform/tizen/channels/platform_channel.cc index 1999309..d206490 100644 --- a/flutter/shell/platform/tizen/channels/platform_channel.cc +++ b/flutter/shell/platform/tizen/channels/platform_channel.cc @@ -135,11 +135,11 @@ void PlatformChannel::HandleMethodCall( "Clipboard API only supports text."); return; } - auto* result_ptr = result.release(); - if (!GetClipboardData([result_ptr](std::optional data) { + std::shared_ptr> result_box{ + std::move(result)}; + if (!GetClipboardData([result_box](std::optional data) { if (!data.has_value()) { - result_ptr->Error(kUnknownClipboardError, "Internal error."); - delete result_ptr; + result_box->Error(kUnknownClipboardError, "Internal error."); return; } @@ -150,11 +150,9 @@ void PlatformChannel::HandleMethodCall( document.AddMember(rapidjson::Value(kTextKey, allocator), rapidjson::Value(data.value(), allocator), allocator); - result_ptr->Success(document); - delete result_ptr; + result_box->Success(document); })) { - result_ptr->Error(kUnknownClipboardError, "Internal error."); - delete result_ptr; + result_box->Error(kUnknownClipboardError, "Internal error."); }; } else if (method == kSetClipboardDataMethod) { if (!arguments) { diff --git a/flutter/shell/platform/tizen/tizen_clipboard.cc b/flutter/shell/platform/tizen/tizen_clipboard.cc index c14d16b..c8393aa 100644 --- a/flutter/shell/platform/tizen/tizen_clipboard.cc +++ b/flutter/shell/platform/tizen/tizen_clipboard.cc @@ -44,6 +44,8 @@ TizenClipboard::TizenClipboard(TizenViewBase* view) { } TizenClipboard::~TizenClipboard() { + on_data_callback_ = nullptr; + ecore_event_handler_del(send_handler); ecore_event_handler_del(receive_handler); } @@ -53,8 +55,13 @@ void TizenClipboard::SendData(void* event) { return; } auto* send_event = reinterpret_cast(event); - if (!send_event->type || strcmp(send_event->type, kMimeTypeTextPlain)) { - FT_LOG(Error) << "Invaild mime type."; + + // TODO(jsuya): If the type of Ecore_Wl2_Event_Data_Source_Send is empty, it + // is assumed to be "text/plain". + if (!send_event->type || (strlen(send_event->type) != 0 && + strcmp(send_event->type, kMimeTypeTextPlain))) { + FT_LOG(Error) << "Invaild mime type(" + << (send_event->type ? send_event->type : "null") << ")."; if (send_event->fd >= 0) { close(send_event->fd); }