[gnome-control-center] online-accounts: Fix crash after aborting web view and changing panels



commit 7ccfa25b47f43161c49b88ddd2502e1f398d45f9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Aug 16 18:53:33 2017 -0300

    online-accounts: Fix crash after aborting web view and changing panels
    
    The panel owns both the GtkDialog, and the GoaProvider that is used
    with the dialog during goa_provider_add_account. When the panel is
    destroyed, it drops its references to the provider but not the dialog,
    which is a separate top-level widget. Therefore, if the panel is
    switched while the WebKitWebView inside the dialog was still
    navigating across pages, then WebKitWebView::decide-policy will be
    called with an invalid provider.
    
    To avoid this, and a memory leak, the panel should also destroy the
    dialog when it is itself getting destructed.
    
    Note that since the GtkDialog is a template child, it must be
    destroyed in dispose. GtkWidget's (ie. the panel's) default default
    destroy signal handler NULLifies all template children pointers, so
    finalize is too late.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782043

 panels/online-accounts/cc-online-accounts-panel.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index 04063d8..0715a0c 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -383,6 +383,17 @@ cc_goa_panel_set_property (GObject *object,
 }
 
 static void
+cc_goa_panel_dispose (GObject *object)
+{
+  CcGoaPanel *panel = CC_GOA_PANEL (object);
+
+  /* Must be destroyed in dispose, not finalize. */
+  g_clear_pointer (&panel->edit_account_dialog, gtk_widget_destroy);
+
+  G_OBJECT_CLASS (cc_goa_panel_parent_class)->dispose (object);
+}
+
+static void
 cc_goa_panel_finalize (GObject *object)
 {
   CcGoaPanel *panel = CC_GOA_PANEL (object);
@@ -495,6 +506,7 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
   object_class->set_property = cc_goa_panel_set_property;
   object_class->finalize = cc_goa_panel_finalize;
   object_class->constructed = cc_goa_panel_constructed;
+  object_class->dispose = cc_goa_panel_dispose;
 
   g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
 


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