From 26acf0730f5bcf01907b3cee20ec1404d1f3d595 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 20 Oct 2020 21:28:50 +0200 Subject: [PATCH] Fix FlTextInputPlugin tear down Closing a Flutter app on Linux with the latest master throws a warning: invalid cast from 'FlView' to 'FlTextInputPlugin' Remarks: - `view_weak_notify_cb()` was trying to cast FlView as `FlTextInputPlugin` - `fl_text_input_plugin_dispose()` was missing `g_object_weak_unref()` A weak ref from `FlTextInputPlugin` to `FlView` seems unnecessary, though, because the `FlTextInputPlugin` instance is managed by `FlView`. It is created in `fl_view_constructed()`, and destroyed in `fl_view_dispose()`. In other words, the `FlTextInputPlugin` instance cannot outlive `FlView`. --- shell/platform/linux/fl_text_input_plugin.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/shell/platform/linux/fl_text_input_plugin.cc b/shell/platform/linux/fl_text_input_plugin.cc index b89e184238c9d..492f0ae6811fb 100644 --- a/shell/platform/linux/fl_text_input_plugin.cc +++ b/shell/platform/linux/fl_text_input_plugin.cc @@ -423,11 +423,6 @@ static void method_call_cb(FlMethodChannel* channel, } } -static void view_weak_notify_cb(gpointer user_data, GObject* object) { - FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(object); - self->view = nullptr; -} - static void fl_text_input_plugin_dispose(GObject* object) { FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(object); @@ -438,6 +433,7 @@ static void fl_text_input_plugin_dispose(GObject* object) { delete self->text_model; self->text_model = nullptr; } + self->view = nullptr; G_OBJECT_CLASS(fl_text_input_plugin_parent_class)->dispose(object); } @@ -483,7 +479,6 @@ FlTextInputPlugin* fl_text_input_plugin_new(FlBinaryMessenger* messenger, fl_method_channel_set_method_call_handler(self->channel, method_call_cb, self, nullptr); self->view = view; - g_object_weak_ref(G_OBJECT(view), view_weak_notify_cb, self); return self; }