[gnome-software] sources dialog: Do teardown in dispose, instead of finalize



commit c6043950c777c5c7231aa2e28b5728e35e04bfde
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Oct 5 22:54:20 2014 +0200

    sources dialog: Do teardown in dispose, instead of finalize
    
    g_cancellable_cancel can lead to a callback from the async task. Doing
    it in finalize is too late, since the template children teardown has
    already happened at that point and we'd crash dereferencing NULL
    pointers in get_sources_cb callback.
    
    Fix this by moving the g_cancellable_cancel() call and the rest of our
    teardown code to the dispose handler, so that it runs before the
    template children destruction.

 src/gs-sources-dialog.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-sources-dialog.c b/src/gs-sources-dialog.c
index 4e7c915..d78d9d5 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -333,7 +333,7 @@ set_plugin_loader (GsSourcesDialog *dialog, GsPluginLoader *plugin_loader)
 }
 
 static void
-gs_sources_dialog_finalize (GObject *object)
+gs_sources_dialog_dispose (GObject *object)
 {
        GsSourcesDialog *dialog = GS_SOURCES_DIALOG (object);
        GsSourcesDialogPrivate *priv = gs_sources_dialog_get_instance_private (dialog);
@@ -345,7 +345,7 @@ gs_sources_dialog_finalize (GObject *object)
                g_clear_object (&priv->cancellable);
        }
 
-       G_OBJECT_CLASS (gs_sources_dialog_parent_class)->finalize (object);
+       G_OBJECT_CLASS (gs_sources_dialog_parent_class)->dispose (object);
 }
 
 static void
@@ -387,7 +387,7 @@ gs_sources_dialog_class_init (GsSourcesDialogClass *klass)
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-       object_class->finalize = gs_sources_dialog_finalize;
+       object_class->dispose = gs_sources_dialog_dispose;
 
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Software/gs-sources-dialog.ui");
 


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