[nautilus/wip/ernestask/649: 2/3] application: Check pending location on clone-window



commit c4889977afdb754abedd0f421149040bb4414c03
Author: Ernestas Kulik <ernestask gnome org>
Date:   Tue Sep 25 09:26:00 2018 +0300

    application: Check pending location on clone-window
    
    Cloning the window while its location is null (i.e. the attributes of
    the pending location file are still being waited on) results in a failed
    assertion, which is less than desirable. That can be fixed by
    preemptively checking if there is a pending location on the slot and
    using that in the new window.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/649

 src/nautilus-application.c | 14 +++++++++++++-
 src/nautilus-window-slot.c | 13 ++++++++++++-
 src/nautilus-window-slot.h |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index cceab8705..203630a77 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -744,7 +744,19 @@ action_clone_window (GSimpleAction *action,
     }
     else
     {
-        location = nautilus_window_slot_get_location (active_slot);
+        /* If the user happens to fall asleep while holding ctrl-n, or very
+         * unfortunately opens a new window at a remote location, the current
+         * location will be null, leading to criticals and/or failed assertions.
+         *
+         * Another sad thing is that checking if the view/slot is loading will
+         * not work, as the loading process only really begins after the attributes
+         * for the file have been fetched.
+         */
+        location = nautilus_window_slot_get_pending_location (active_slot);
+        if (location == NULL)
+        {
+            location = nautilus_window_slot_get_location (active_slot);
+        }
     }
 
     nautilus_application_open_location_full (NAUTILUS_APPLICATION (application), location,
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index b3a7bc211..7aa553b4f 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -1859,7 +1859,6 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
     NautilusFile *viewed_file;
     NautilusView *view;
     GFile *location;
-
     NautilusApplication *app;
 
     self = callback_data;
@@ -3232,6 +3231,18 @@ nautilus_window_slot_get_location (NautilusWindowSlot *self)
     return priv->location;
 }
 
+GFile *
+nautilus_window_slot_get_pending_location (NautilusWindowSlot *self)
+{
+    NautilusWindowSlotPrivate *priv;
+
+    g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (self), NULL);
+
+    priv = nautilus_window_slot_get_instance_private (self);
+
+    return priv->pending_location;
+}
+
 const gchar *
 nautilus_window_slot_get_title (NautilusWindowSlot *self)
 {
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index e2e0d7592..b4f15b04a 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -77,6 +77,7 @@ void nautilus_window_slot_open_location_full              (NautilusWindowSlot
                                                            GList                   *new_selection);
 
 GFile * nautilus_window_slot_get_location                 (NautilusWindowSlot *slot);
+GFile * nautilus_window_slot_get_pending_location          (NautilusWindowSlot *slot);
 
 NautilusBookmark *nautilus_window_slot_get_bookmark        (NautilusWindowSlot *slot);
 


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