Blob Blame History Raw
From e03af2e1a49bf25a8968c29f376fb5652aabd577 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 17 Sep 2013 17:19:20 +0200
Subject: [PATCH] privacy: Don't leak the dialogs

https://bugzilla.gnome.org/show_bug.cgi?id=708286
---
 panels/privacy/cc-privacy-panel.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/panels/privacy/cc-privacy-panel.c b/panels/privacy/cc-privacy-panel.c
index 13e87e0..e99f0e2 100644
--- a/panels/privacy/cc-privacy-panel.c
+++ b/panels/privacy/cc-privacy-panel.c
@@ -39,6 +39,9 @@ CC_PANEL_REGISTER (CcPrivacyPanel, cc_privacy_panel)
 struct _CcPrivacyPanelPrivate
 {
   GtkBuilder *builder;
+  GtkWidget  *recent_dialog;
+  GtkWidget  *screen_lock_dialog;
+  GtkWidget  *trash_dialog;
   GtkWidget  *list_box;
 
   GSettings  *lockdown_settings;
@@ -271,7 +274,7 @@ add_screen_lock (CcPrivacyPanel *self)
   add_row (self, _("Screen Lock"), "screen_lock_dialog", w);
 
   w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "screen_lock_done"));
-  dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "screen_lock_dialog"));
+  dialog = self->priv->screen_lock_dialog;
   g_signal_connect_swapped (w, "clicked",
                             G_CALLBACK (gtk_widget_hide), dialog);
   g_signal_connect (dialog, "delete-event",
@@ -446,7 +449,7 @@ add_usage_history (CcPrivacyPanel *self)
   add_row (self, _("Usage & History"), "recent_dialog", w);
 
   w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "recent_done"));
-  dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "recent_dialog"));
+  dialog = self->priv->recent_dialog;
   g_signal_connect_swapped (w, "clicked",
                             G_CALLBACK (gtk_widget_hide), dialog);
   g_signal_connect (dialog, "delete-event",
@@ -576,7 +579,7 @@ add_trash_temp (CcPrivacyPanel *self)
   add_row (self, _("Purge Trash & Temporary Files"), "trash_dialog", w);
 
   w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "trash_done"));
-  dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "trash_dialog"));
+  dialog = self->priv->trash_dialog;
   g_signal_connect_swapped (w, "clicked",
                             G_CALLBACK (gtk_widget_hide), dialog);
   g_signal_connect (dialog, "delete-event",
@@ -610,6 +613,9 @@ cc_privacy_panel_finalize (GObject *object)
 {
   CcPrivacyPanelPrivate *priv = CC_PRIVACY_PANEL (object)->priv;
 
+  g_clear_pointer (&priv->recent_dialog, gtk_widget_destroy);
+  g_clear_pointer (&priv->screen_lock_dialog, gtk_widget_destroy);
+  g_clear_pointer (&priv->trash_dialog, gtk_widget_destroy);
   g_clear_object (&priv->builder);
   g_clear_object (&priv->lockdown_settings);
   g_clear_object (&priv->lock_settings);
@@ -684,6 +690,10 @@ cc_privacy_panel_init (CcPrivacyPanel *self)
       return;
     }
 
+  self->priv->recent_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "recent_dialog"));
+  self->priv->screen_lock_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "screen_lock_dialog"));
+  self->priv->trash_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "trash_dialog"));
+
   frame = WID ("frame");
   widget = GTK_WIDGET (egg_list_box_new ());
   egg_list_box_set_selection_mode (EGG_LIST_BOX (widget), GTK_SELECTION_NONE);
-- 
1.8.4.2