commit 90eb8f3486dc0972fec505830de8cc8a416658ae
Author: Philip Langdale <philipl@overt.org>
Date:   Wed Jan 23 11:54:29 2013 -0800

    MTP: Fix leaked weak reference on monitors.
    
    We use a weak reference to automatically clean up the monitor
    hash table when monitors are finalized. However, we still need
    to remember to remove the weak references when the backend is
    itself finalized - otherwise the reference might be fired later
    if a monitor happens to get finalized before the backend exits
    completely.

diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index a39e4d1..efd1943 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -131,6 +131,14 @@ g_vfs_backend_mtp_init (GVfsBackendMtp *backend)
 }
 
 static void
+remove_monitor_weak_ref (gpointer monitor,
+                         gpointer unused,
+                         gpointer monitors)
+{
+  g_object_weak_unref (G_OBJECT(monitor), (GWeakNotify)g_hash_table_remove, monitors);
+}
+
+static void
 g_vfs_backend_mtp_finalize (GObject *object)
 {
   GVfsBackendMtp *backend;
@@ -139,6 +147,7 @@ g_vfs_backend_mtp_finalize (GObject *object)
 
   backend = G_VFS_BACKEND_MTP (object);
 
+  g_hash_table_foreach (backend->monitors, remove_monitor_weak_ref, backend->monitors);
   g_hash_table_unref (backend->monitors);
   g_mutex_clear (&backend->mutex);
 
