[gnome-control-center] region: Fix memory leaks and destroy dialogue properly



commit 0c8dd1aebc2240491ca66fe306f3f4749d16278d
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 24 17:31:47 2011 +0000

    region: Fix memory leaks and destroy dialogue properly
    
    There's no top-level dialogue any more, so we need some way to
    clean up after ourselves.

 panels/region/cc-region-panel.c        |    2 ++
 panels/region/gnome-region-panel-xkb.c |   12 +++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index e2e62c6..83a706d 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -65,6 +65,8 @@ cc_region_panel_dispose (GObject * object)
 	CcRegionPanelPrivate *priv = CC_REGION_PANEL (object)->priv;
 
 	if (priv->builder) {
+		GtkBuilder *dialog = priv->builder;
+		gtk_widget_destroy (WID ("region_notebook"));
 		g_object_unref (priv->builder);
 		priv->builder = NULL;
 	}
diff --git a/panels/region/gnome-region-panel-xkb.c b/panels/region/gnome-region-panel-xkb.c
index bc32099..8c1de4c 100644
--- a/panels/region/gnome-region-panel-xkb.c
+++ b/panels/region/gnome-region-panel-xkb.c
@@ -99,13 +99,16 @@ setup_model_entry (GtkBuilder * dialog)
 }
 
 static void
-cleanup_xkb_tabs (GtkBuilder * dialog)
+cleanup_xkb_tabs (GtkBuilder * dialog,
+		  GObject *where_the_object_wa)
 {
+	g_message ("cleanup_xkb_tabs running");
+
 	gkbd_desktop_config_term (&desktop_config);
 	gkbd_keyboard_config_term (&initial_config);
 	g_object_unref (G_OBJECT (config_registry));
 	config_registry = NULL;
-	g_object_unref (G_OBJECT (engine));
+	/* Don't unref it here, or we'll crash if open the panel again */
 	engine = NULL;
 	g_object_unref (G_OBJECT (xkb_keyboard_settings));
 	g_object_unref (G_OBJECT (xkb_desktop_settings));
@@ -225,9 +228,8 @@ setup_xkb_tabs (GtkBuilder * dialog)
 	xkb_layouts_register_conf_listener (dialog);
 	xkb_options_register_conf_listener (dialog);
 
-	g_signal_connect (G_OBJECT (WID ("region_dialog")),
-			  "destroy", G_CALLBACK (cleanup_xkb_tabs),
-			  dialog);
+	g_object_weak_ref (G_OBJECT (WID ("region_notebook")),
+			   (GWeakNotify) cleanup_xkb_tabs, dialog);
 
 	enable_disable_restoring (dialog);
 }



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