← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~robert-ancell/activity-log-manager/proxy-unref into lp:activity-log-manager

 

Robert Ancell has proposed merging lp:~robert-ancell/activity-log-manager/proxy-unref into lp:activity-log-manager.

Commit message:
Destroy DBus proxy when preferences widget is destroyed

Requested reviews:
  Activity Log Manager (activity-log-manager)
Related bugs:
  Bug #1275736 in activity-log-manager (Ubuntu): "/usr/bin/gnome-control-center.real:11:gtk_builder_get_object:on_properties_changed:ffi_call_unix64:ffi_call:g_cclosure_marshal_generic"
  https://bugs.launchpad.net/ubuntu/+source/activity-log-manager/+bug/1275736

For more details, see:
https://code.launchpad.net/~robert-ancell/activity-log-manager/proxy-unref/+merge/204489
-- 
https://code.launchpad.net/~robert-ancell/activity-log-manager/proxy-unref/+merge/204489
Your team Activity Log Manager is requested to review the proposed merge of lp:~robert-ancell/activity-log-manager/proxy-unref into lp:activity-log-manager.
=== modified file 'src/diagnostics-widget.c'
--- src/diagnostics-widget.c	2013-07-19 10:31:55 +0000
+++ src/diagnostics-widget.c	2014-02-03 13:48:17 +0000
@@ -8,8 +8,6 @@
 
 #include "whoopsie-preferences/libwhoopsie-preferences.h"
 
-static WhoopsiePreferences* proxy = NULL;
-
 #define POL_PATH "com.ubuntu.whoopsiepreferences.change"
 #define PRIVACY_URL "http://www.ubuntu.com/aboutus/privacypolicy?crashdb";
 #define SYSTEM_ERRORS_URL "https://errors.ubuntu.com/user";
@@ -31,6 +29,7 @@
 {
     GtkBuilder* builder;
     GPermission* permission;
+    WhoopsiePreferences* proxy;
 };
 
 struct _WhoopsieDaisyPreferences
@@ -59,6 +58,10 @@
         g_object_unref (priv->permission);
         priv->permission = NULL;
     }
+    if (priv->proxy) {
+        g_object_unref (priv->proxy);
+        priv->proxy = NULL;
+    }
 }
 
 static void
@@ -79,10 +82,12 @@
 static void
 on_show_previous_reports_clicked (GtkWidget* button, gpointer user_data)
 {
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (user_data)->priv;
     GError* error = NULL;
     gchar* identifier = NULL;
     gchar* command = NULL;
-    whoopsie_preferences_call_get_identifier_sync (proxy, &identifier, NULL, &error);
+
+    whoopsie_preferences_call_get_identifier_sync (priv->proxy, &identifier, NULL, &error);
 
     if (!error) {
         asprintf (&command, "xdg-open " SYSTEM_ERRORS_URL "/%s", identifier);
@@ -117,9 +122,10 @@
 static void
 on_submit_error_reports_checked (GtkToggleButton* button, gpointer user_data)
 {
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (user_data)->priv;
     GError* error = NULL;
 
-    whoopsie_preferences_call_set_report_crashes_sync (proxy,
+    whoopsie_preferences_call_set_report_crashes_sync (priv->proxy,
         gtk_toggle_button_get_active (button), NULL, &error);
     if (error != NULL) {
         g_printerr ("Error setting crash reporting: %s\n", error->message);
@@ -130,9 +136,10 @@
 static void
 on_submit_metrics_reports_checked (GtkToggleButton* button, gpointer user_data)
 {
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (user_data)->priv;
     GError* error = NULL;
 
-    whoopsie_preferences_call_set_report_metrics_sync (proxy,
+    whoopsie_preferences_call_set_report_metrics_sync (priv->proxy,
         gtk_toggle_button_get_active (button), NULL, &error);
     if (error != NULL) {
         g_printerr ("Error setting metrics reporting: %s\n", error->message);
@@ -166,17 +173,19 @@
 static void
 whoopsie_daisy_preferences_setup_dbus (WhoopsieDaisyPreferences *self, GError *error)
 {
-    proxy = whoopsie_preferences_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+    WhoopsieDaisyPreferencesPrivate* priv = self->priv;
+
+    priv->proxy = whoopsie_preferences_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                          G_DBUS_PROXY_FLAGS_NONE,
                                          "com.ubuntu.WhoopsiePreferences",
                                          "/com/ubuntu/WhoopsiePreferences",
                                          NULL, &error);
-    if (!proxy)
+    if (!priv->proxy)
         return;
 
-    g_signal_connect (proxy, "g-properties-changed",
+    g_signal_connect (priv->proxy, "g-properties-changed",
                                    G_CALLBACK (on_properties_changed), self);
-    on_properties_changed (proxy, NULL, NULL, self);
+    on_properties_changed (priv->proxy, NULL, NULL, self);
 }
 static void
 whoopsie_daisy_preferences_init (WhoopsieDaisyPreferences *self)
@@ -237,13 +246,13 @@
     }
 
     g_signal_connect (submit_error_reports, "toggled",
-                      G_CALLBACK (on_submit_error_reports_checked), NULL);
+                      G_CALLBACK (on_submit_error_reports_checked), self);
     g_signal_connect (submit_metrics_reports, "toggled",
-                      G_CALLBACK (on_submit_metrics_reports_checked), NULL);
+                      G_CALLBACK (on_submit_metrics_reports_checked), self);
     g_signal_connect (privacy_policy, "clicked",
-                      G_CALLBACK (on_privacy_policy_clicked), NULL);
+                      G_CALLBACK (on_privacy_policy_clicked), self);
     g_signal_connect (show_previous_reports, "clicked",
-                      G_CALLBACK (on_show_previous_reports_clicked), NULL);
+                      G_CALLBACK (on_show_previous_reports_clicked), self);
 }
 
 GtkWidget*


References