[gtk+/gtk-3-4] GtkImage: Move g_clear_object() to gtk_image_finalize()



commit 02eef4951e3ca161f6f41e0116755531c4866f6d
Author: Michael Vogt <mvo ubuntu com>
Date:   Mon Apr 16 06:51:43 2012 +0200

    GtkImage: Move g_clear_object() to gtk_image_finalize()
    
    This moves the freeing of the icon_helper from the destory to the finalize
    function to avoid segfaults when trying to access a destroyed object before it
    is disposed. This often happens in signal handlers which get called
    asynchronously after destroy.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674050

 gtk/gtkimage.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index fa87ea7..14f3efc 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -157,7 +157,7 @@ static void gtk_image_get_preferred_height (GtkWidget    *widget,
 static void gtk_image_style_updated        (GtkWidget    *widget);
 static void gtk_image_screen_changed       (GtkWidget    *widget,
                                             GdkScreen    *prev_screen);
-static void gtk_image_destroy              (GtkWidget    *widget);
+static void gtk_image_finalize             (GObject      *object);
 static void gtk_image_reset                (GtkImage     *image);
 
 static void gtk_image_set_property         (GObject      *object,
@@ -199,10 +199,10 @@ gtk_image_class_init (GtkImageClass *class)
   
   gobject_class->set_property = gtk_image_set_property;
   gobject_class->get_property = gtk_image_get_property;
+  gobject_class->finalize = gtk_image_finalize;
 
   widget_class = GTK_WIDGET_CLASS (class);
   widget_class->draw = gtk_image_draw;
-  widget_class->destroy = gtk_image_destroy;
   widget_class->get_preferred_width = gtk_image_get_preferred_width;
   widget_class->get_preferred_height = gtk_image_get_preferred_height;
   widget_class->unmap = gtk_image_unmap;
@@ -359,14 +359,14 @@ gtk_image_init (GtkImage *image)
 }
 
 static void
-gtk_image_destroy (GtkWidget *widget)
+gtk_image_finalize (GObject *object)
 {
-  GtkImage *image = GTK_IMAGE (widget);
+  GtkImage *image = GTK_IMAGE (object);
 
   g_clear_object (&image->priv->icon_helper);
-
-  GTK_WIDGET_CLASS (gtk_image_parent_class)->destroy (widget);
-}
+  
+  G_OBJECT_CLASS (gtk_image_parent_class)->finalize (object);
+};
 
 static void 
 gtk_image_set_property (GObject      *object,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]