diff --git a/engine/src/flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc b/engine/src/flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc index 20154101d1..9f6a858bf1 100644 --- a/engine/src/flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc +++ b/engine/src/flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc @@ -140,20 +140,13 @@ static void method_call_cb(FlMethodChannel* channel, } } -static void view_weak_notify_cb(gpointer user_data, - GObject* where_the_object_was) { - FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN(user_data); - self->view = nullptr; -} - static void fl_mouse_cursor_plugin_dispose(GObject* object) { FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN(object); g_clear_object(&self->channel); - if (self->view != nullptr) { - g_object_weak_unref(G_OBJECT(self->view), view_weak_notify_cb, self); - self->view = nullptr; - } + g_object_remove_weak_pointer(G_OBJECT(self->view), + reinterpret_cast(&(self->view))); + self->view = nullptr; g_clear_pointer(&self->system_cursor_table, g_hash_table_unref); @@ -179,7 +172,10 @@ FlMouseCursorPlugin* fl_mouse_cursor_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); + if (view != nullptr) { + g_object_add_weak_pointer(G_OBJECT(view), + reinterpret_cast(&(self->view))); + } return self; } diff --git a/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc b/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc index 7e7a7f1cab..cf23198509 100644 --- a/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc +++ b/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc @@ -22,20 +22,12 @@ G_MODULE_EXPORT GType fl_plugin_registrar_get_type(); G_DEFINE_TYPE(FlPluginRegistrar, fl_plugin_registrar, G_TYPE_OBJECT) -static void view_weak_notify_cb(gpointer user_data, - GObject* where_the_object_was) { - FlPluginRegistrar* self = FL_PLUGIN_REGISTRAR(user_data); - self->view = nullptr; -} - static void fl_plugin_registrar_dispose(GObject* object) { FlPluginRegistrar* self = FL_PLUGIN_REGISTRAR(object); - if (self->view != nullptr) { - g_object_weak_unref(G_OBJECT(self->view), view_weak_notify_cb, self); - self->view = nullptr; - } - + g_object_remove_weak_pointer(G_OBJECT(self->view), + reinterpret_cast(&(self->view))); + self->view = nullptr; g_clear_object(&self->messenger); G_OBJECT_CLASS(fl_plugin_registrar_parent_class)->dispose(object); @@ -56,8 +48,10 @@ FlPluginRegistrar* fl_plugin_registrar_new(FlView* view, g_object_new(fl_plugin_registrar_get_type(), nullptr)); self->view = view; - if (view != nullptr) - g_object_weak_ref(G_OBJECT(view), view_weak_notify_cb, self); + if (view != nullptr) { + g_object_add_weak_pointer(G_OBJECT(view), + reinterpret_cast(&(self->view))); + } self->messenger = FL_BINARY_MESSENGER(g_object_ref(messenger)); return self;