Blame SOURCES/gvfs-1.22.5-proxy-volume-monitor-Properly-handle-failure-to-crea.patch

9e08f4
From cad2b5de5d8e828405e3b2970855d7079cb972c2 Mon Sep 17 00:00:00 2001
9e08f4
From: Debarshi Ray <debarshir@gnome.org>
9e08f4
Date: Fri, 16 Oct 2015 13:35:34 +0200
9e08f4
Subject: [PATCH] proxy volume monitor: Properly handle failure to create a
9e08f4
 remote proxy
9e08f4
9e08f4
We should finish constructing the innards of the object and not leave
9e08f4
it in an inconsistent state when we hit an error. The other option
9e08f4
would be to litter the rest of the code with NULL checks, but that
9e08f4
would be ugly and prone to errors.
9e08f4
9e08f4
We should also ensure that the reference counting stays consistent with
9e08f4
the non-error paths.
9e08f4
9e08f4
https://bugzilla.gnome.org/show_bug.cgi?id=755805
9e08f4
---
9e08f4
 monitor/proxy/gproxyvolumemonitor.c | 15 ++++++---------
9e08f4
 1 file changed, 6 insertions(+), 9 deletions(-)
9e08f4
9e08f4
diff --git a/monitor/proxy/gproxyvolumemonitor.c b/monitor/proxy/gproxyvolumemonitor.c
9e08f4
index 17474a84bc64..a7466f0efd96 100644
9e08f4
--- a/monitor/proxy/gproxyvolumemonitor.c
9e08f4
+++ b/monitor/proxy/gproxyvolumemonitor.c
9e08f4
@@ -972,10 +972,7 @@ g_proxy_volume_monitor_constructor (GType                  type,
9e08f4
   klass = G_PROXY_VOLUME_MONITOR_CLASS (g_type_class_peek (type));
9e08f4
   object = g_hash_table_lookup (the_volume_monitors, (gpointer) type);
9e08f4
   if (object != NULL)
9e08f4
-    {
9e08f4
-      g_object_ref (object);
9e08f4
-      goto out;
9e08f4
-    }
9e08f4
+    goto out;
9e08f4
 
9e08f4
   dbus_name = klass->dbus_name;
9e08f4
 
9e08f4
@@ -988,6 +985,10 @@ g_proxy_volume_monitor_constructor (GType                  type,
9e08f4
 
9e08f4
   monitor = G_PROXY_VOLUME_MONITOR (object);
9e08f4
 
9e08f4
+  monitor->drives = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
+  monitor->volumes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
+  monitor->mounts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
+
9e08f4
   error = NULL;
9e08f4
   monitor->proxy = gvfs_remote_volume_monitor_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
9e08f4
                                                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
9e08f4
@@ -1022,10 +1023,6 @@ g_proxy_volume_monitor_constructor (GType                  type,
9e08f4
   g_signal_connect (monitor->proxy, "volume-changed", G_CALLBACK (volume_changed), monitor);
9e08f4
   g_signal_connect (monitor->proxy, "volume-removed", G_CALLBACK (volume_removed), monitor);
9e08f4
 
9e08f4
-  monitor->drives = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
-  monitor->volumes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
-  monitor->mounts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
9e08f4
-
9e08f4
   /* listen to when the owner of the service appears/disappears */
9e08f4
   g_signal_connect (monitor->proxy, "notify::g-name-owner", G_CALLBACK (name_owner_changed), monitor);
9e08f4
   /* initially seed drives/volumes/mounts if we have an owner */
9e08f4
@@ -1038,12 +1035,12 @@ g_proxy_volume_monitor_constructor (GType                  type,
9e08f4
 
9e08f4
   g_hash_table_insert (the_volume_monitors, (gpointer) type, object);
9e08f4
 
9e08f4
+ out:
9e08f4
   /* Take an extra reference to make the instance live forever - see also
9e08f4
    * the dispose() and finalize() vfuncs
9e08f4
    */
9e08f4
   g_object_ref (object);
9e08f4
 
9e08f4
- out:
9e08f4
   G_UNLOCK (proxy_vm);
9e08f4
   return object;
9e08f4
 }
9e08f4
-- 
9e08f4
2.5.0
9e08f4