From 486f8e4886df5d53b08bdf124d2b5778411a9361 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Tue, 2 Jun 2020 11:32:57 +1200 Subject: [PATCH] Don't show warnings when removing handlers. (flutter/engine#18633) These are removed in destructors. --- .../shell/platform/linux/fl_basic_message_channel.cc | 6 ++++-- .../flutter/shell/platform/linux/fl_binary_messenger.cc | 8 +++++--- .../src/flutter/shell/platform/linux/fl_method_channel.cc | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/shell/platform/linux/fl_basic_message_channel.cc b/engine/src/flutter/shell/platform/linux/fl_basic_message_channel.cc index be5ad98b12d..ccb20ad4f64 100644 --- a/engine/src/flutter/shell/platform/linux/fl_basic_message_channel.cc +++ b/engine/src/flutter/shell/platform/linux/fl_basic_message_channel.cc @@ -182,8 +182,10 @@ G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler( // Don't set handler if channel closed if (self->channel_closed) { - g_warning( - "Attempted to set message handler on closed FlBasicMessageChannel"); + if (handler != nullptr) { + g_warning( + "Attempted to set message handler on a closed FlBasicMessageChannel"); + } if (destroy_notify != nullptr) destroy_notify(user_data); return; diff --git a/engine/src/flutter/shell/platform/linux/fl_binary_messenger.cc b/engine/src/flutter/shell/platform/linux/fl_binary_messenger.cc index 50a8c21f9af..3d624a8cbe8 100644 --- a/engine/src/flutter/shell/platform/linux/fl_binary_messenger.cc +++ b/engine/src/flutter/shell/platform/linux/fl_binary_messenger.cc @@ -175,9 +175,11 @@ G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel( // Don't set handlers if engine already gone if (self->engine == nullptr) { - g_warning( - "Attempted to set message handler on closed FlBinaryMessenger without " - "engine"); + if (handler != nullptr) { + g_warning( + "Attempted to set message handler on an FlBinaryMessenger without an " + "engine"); + } if (destroy_notify != nullptr) destroy_notify(user_data); return; diff --git a/engine/src/flutter/shell/platform/linux/fl_method_channel.cc b/engine/src/flutter/shell/platform/linux/fl_method_channel.cc index b2ea8dcb616..5b52173f0ee 100644 --- a/engine/src/flutter/shell/platform/linux/fl_method_channel.cc +++ b/engine/src/flutter/shell/platform/linux/fl_method_channel.cc @@ -140,7 +140,10 @@ G_MODULE_EXPORT void fl_method_channel_set_method_call_handler( // Don't set handler if channel closed if (self->channel_closed) { - g_warning("Attempted to set method call handler on closed FlMethodChannel"); + if (handler != nullptr) { + g_warning( + "Attempted to set method call handler on a closed FlMethodChannel"); + } if (destroy_notify != nullptr) destroy_notify(user_data); return;