diff --git a/engine/src/flutter/shell/platform/linux/fl_key_event_plugin.cc b/engine/src/flutter/shell/platform/linux/fl_key_event_plugin.cc index d7be670895..2bbc6cfe52 100644 --- a/engine/src/flutter/shell/platform/linux/fl_key_event_plugin.cc +++ b/engine/src/flutter/shell/platform/linux/fl_key_event_plugin.cc @@ -115,9 +115,11 @@ G_DEFINE_TYPE(FlKeyEventResponseData, fl_key_event_response_data, G_TYPE_OBJECT) static void fl_key_event_response_data_dispose(GObject* object) { g_return_if_fail(FL_IS_KEY_EVENT_RESPONSE_DATA(object)); FlKeyEventResponseData* self = FL_KEY_EVENT_RESPONSE_DATA(object); - // Don't need to weak pointer anymore. - g_object_remove_weak_pointer(G_OBJECT(self->plugin), - reinterpret_cast(&(self->plugin))); + if (self->plugin != nullptr) { + g_object_remove_weak_pointer(G_OBJECT(self->plugin), + reinterpret_cast(&(self->plugin))); + self->plugin = nullptr; + } } // Class initialization method for FlKeyEventResponseData private class. @@ -267,9 +269,12 @@ static void fl_key_event_plugin_dispose(GObject* object) { FlKeyEventPlugin* self = FL_KEY_EVENT_PLUGIN(object); g_clear_object(&self->channel); - g_object_remove_weak_pointer( - G_OBJECT(self->text_input_plugin), - reinterpret_cast(&(self->text_input_plugin))); + if (self->text_input_plugin != nullptr) { + g_object_remove_weak_pointer( + G_OBJECT(self->text_input_plugin), + reinterpret_cast(&(self->text_input_plugin))); + self->text_input_plugin = nullptr; + } g_ptr_array_free(self->pending_events, TRUE); G_OBJECT_CLASS(fl_key_event_plugin_parent_class)->dispose(object); 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 9f6a858bf1..79cad6f774 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 @@ -144,10 +144,11 @@ static void fl_mouse_cursor_plugin_dispose(GObject* object) { FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN(object); g_clear_object(&self->channel); - g_object_remove_weak_pointer(G_OBJECT(self->view), - reinterpret_cast(&(self->view))); - self->view = nullptr; - + if (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); G_OBJECT_CLASS(fl_mouse_cursor_plugin_parent_class)->dispose(object); 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 cf23198509..5207497b2f 100644 --- a/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc +++ b/engine/src/flutter/shell/platform/linux/fl_plugin_registrar.cc @@ -25,9 +25,11 @@ G_DEFINE_TYPE(FlPluginRegistrar, fl_plugin_registrar, G_TYPE_OBJECT) static void fl_plugin_registrar_dispose(GObject* object) { FlPluginRegistrar* self = FL_PLUGIN_REGISTRAR(object); - g_object_remove_weak_pointer(G_OBJECT(self->view), - reinterpret_cast(&(self->view))); - self->view = nullptr; + if (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);