[nautilus] monitor: improve unmount detect heuristic



commit a23ed4ad0173ca7a51e26282b85d06ce4b25912a
Author: Daniel Schürmann <daschuer gmx de>
Date:   Sun Feb 16 22:44:48 2014 +0100

    monitor: improve unmount detect heuristic
    
    Detect when an unmount happens and a subfolder of the mount is
    displayed. The previous solution did a GMount pointer compare, but this
    was not working in any case.
    This patch fixes is by comparing the removed mount root with the
    currently monitored location.
    This fixes a regression since 0852847e2613dbcebb4ed7f58e5b2aee3aa86a90.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724560

 libnautilus-private/nautilus-monitor.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libnautilus-private/nautilus-monitor.c b/libnautilus-private/nautilus-monitor.c
index 5b21c24..484c75b 100644
--- a/libnautilus-private/nautilus-monitor.c
+++ b/libnautilus-private/nautilus-monitor.c
@@ -32,7 +32,6 @@
 struct NautilusMonitor {
        GFileMonitor *monitor;
        GVolumeMonitor *volume_monitor;
-       GMount *mount;
        GFile *location;
 };
 
@@ -85,11 +84,16 @@ mount_removed (GVolumeMonitor *volume_monitor,
               gpointer user_data)
 {
        NautilusMonitor *monitor = user_data;
+       GFile *mount_location;
 
-       if (mount == monitor->mount) {
+       mount_location = g_mount_get_root (mount);
+
+       if (g_file_has_prefix (monitor->location, mount_location)) {
                nautilus_file_changes_queue_file_removed (monitor->location);
                schedule_call_consume_changes ();
        }
+
+       g_object_unref (mount_location);
 }
 
 static void
@@ -143,7 +147,6 @@ nautilus_monitor_directory (GFile *location)
        if (dir_monitor != NULL) {
                ret->monitor = dir_monitor;
        } else if (!g_file_is_native (location)) {
-               ret->mount = nautilus_get_mounted_mount_for_root (location);
                ret->location = g_object_ref (location);
                ret->volume_monitor = g_volume_monitor_get ();
        }
@@ -177,6 +180,5 @@ nautilus_monitor_cancel (NautilusMonitor *monitor)
        }
 
        g_clear_object (&monitor->location);
-       g_clear_object (&monitor->mount);
        g_slice_free (NautilusMonitor, monitor);
 }


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