[gtk+/gtk-3-14] widget: Free the controller list on finalize()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] widget: Free the controller list on finalize()
- Date: Wed, 14 Jan 2015 16:45:32 +0000 (UTC)
commit 485ab7a3d93901b864cf860db17af046736246ef
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 14 16:59:36 2015 +0100
widget: Free the controller list on finalize()
If this is done on dispose(), the widget may be destroyed (and its
controllers list NULLified) within _gtk_widget_run_controllers(),
causing warnings/crashes when it just tried to hop on the next
controllers.
Freeing the controllers here should be a safety net for implementations,
so it also makes sense to do this late. The widgets that choose to
free their controllers on dispose can still do so, and get
_gtk_widget_remove_controller() called for these as an indirect result.
gtk/gtkwidget.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 2b81bc1..d0683ec 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11907,7 +11907,6 @@ gtk_widget_dispose (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetPrivate *priv = widget->priv;
- GList *l;
if (priv->parent)
gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
@@ -11930,15 +11929,6 @@ gtk_widget_dispose (GObject *object)
while (priv->attached_windows)
gtk_window_set_attached_to (priv->attached_windows->data, NULL);
- for (l = priv->event_controllers; l; l = l->next)
- {
- EventControllerData *data = l->data;
- if (data->controller)
- _gtk_widget_remove_controller (widget, data->controller);
- }
- g_list_free_full (priv->event_controllers, g_free);
- priv->event_controllers = NULL;
-
G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
}
@@ -12133,6 +12123,7 @@ gtk_widget_finalize (GObject *object)
GtkWidgetPrivate *priv = widget->priv;
GtkWidgetAuxInfo *aux_info;
GtkAccessible *accessible;
+ GList *l;
gtk_grab_remove (widget);
@@ -12159,6 +12150,15 @@ gtk_widget_finalize (GObject *object)
_gtk_size_request_cache_free (&priv->requests);
+ for (l = priv->event_controllers; l; l = l->next)
+ {
+ EventControllerData *data = l->data;
+ if (data->controller)
+ _gtk_widget_remove_controller (widget, data->controller);
+ }
+ g_list_free_full (priv->event_controllers, g_free);
+ priv->event_controllers = NULL;
+
if (g_object_is_floating (object))
g_warning ("A floating object was finalized. This means that someone\n"
"called g_object_unref() on an object that had only a floating\n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]