Force reload current location when it reappears

Resolves: rhbz#2184292
This commit is contained in:
Ondrej Holy 2023-06-14 16:32:03 +02:00
parent 395b5f7899
commit 3503231682
5 changed files with 190 additions and 2 deletions

View File

@ -0,0 +1,42 @@
From e03d731e3dcb8d0f52ffbc6faa188802b742d1e9 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Thu, 26 Jan 2023 13:20:51 +0100
Subject: [PATCH] file-utilities: Prevent passing NULL to g_object_unref
The `nautilus_find_existing_uri_in_hierarchy` function calls the
`g_object_unref` with a `NULL` pointer when `g_file_query_info` fails.
This leads to a crash e.g. when parent directory of the currently
opened location is removed. Let's port the code to use `g_autoptr` to
avoid that.
---
src/nautilus-file-utilities.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index e8f1ca2fb..1c913dbad 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -598,7 +598,6 @@ nautilus_generate_unique_file_in_directory (GFile *directory,
GFile *
nautilus_find_existing_uri_in_hierarchy (GFile *location)
{
- GFileInfo *info;
GFile *tmp;
g_assert (location != NULL);
@@ -606,10 +605,11 @@ nautilus_find_existing_uri_in_hierarchy (GFile *location)
location = g_object_ref (location);
while (location != NULL)
{
+ g_autoptr (GFileInfo) info = NULL;
+
info = g_file_query_info (location,
G_FILE_ATTRIBUTE_STANDARD_NAME,
0, NULL, NULL);
- g_object_unref (info);
if (info != NULL)
{
return location;
--
2.40.0

View File

@ -6,7 +6,7 @@
Name: nautilus
Version: 40.2
Release: 13%{?dist}
Release: 14%{?dist}
Summary: File manager for GNOME
License: GPLv3+
@ -41,9 +41,13 @@ Patch15: freedesktop-dbus-Try-to-own-the-name-until-after-exp.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2184292
Patch16: window-slot-Try-current-location-even-if-it-is-marke.patch
Patch17: window-slot-Force-reload-current-location-when-it-re.patch
Patch18: pathbar-Do-nothing-when-current-location-disappears.patch
Patch19: file-utilities-Prevent-passing-NULL-to-g_object_unre.patch
Patch20: window-slot-Fix-conditions-to-restore-selection-when.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2120263
Patch17: file-Generate-thumbnails-when-the-preview-icon-is-av.patch
Patch21: file-Generate-thumbnails-when-the-preview-icon-is-av.patch
BuildRequires: desktop-file-utils
BuildRequires: gcc
@ -175,6 +179,9 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/*.desktop
%doc %{_datadir}/gtk-doc/html/libnautilus-extension/
%changelog
* Wed Jun 14 2023 Ondrej Holy <oholy@redhat.com> - 40.2-14
- Force reload current location when it reappears (#2184292)
* Thu Apr 06 2023 Ondrej Holy <oholy@redhat.com> - 40.2-13
- Generate thumbnails when the preview icon is available (#2120263)

View File

@ -0,0 +1,59 @@
From 151af5733a11dc4aceb8ecf4c9eeafcaab188451 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Fri, 27 Jan 2023 11:02:22 +0100
Subject: [PATCH] pathbar: Do nothing when current location disappears
The pathbar automatically clear all the buttons when the current location
is marked as gone. This was needed earlier, when child folders where shown
in some cases, but this is no more needed nowadays. Let's drop that code.
---
src/nautilus-pathbar.c | 33 +--------------------------------
1 file changed, 1 insertion(+), 32 deletions(-)
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index edc0fff56..4bd9ff5b2 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -1445,38 +1445,7 @@ button_data_file_changed (NautilusFile *file,
}
else if (nautilus_file_is_gone (file))
{
- gint idx, position;
-
- /* if the current or a parent location are gone, clear all the buttons,
- * the view will set the new path.
- */
- current_location = nautilus_file_get_location (current_button_data->file);
-
- if (g_file_has_prefix (current_location, location) ||
- g_file_equal (current_location, location))
- {
- nautilus_path_bar_clear_buttons (self);
- }
- else if (g_file_has_prefix (location, current_location))
- {
- /* remove this and the following buttons */
- position = g_list_position (self->button_list,
- g_list_find (self->button_list, button_data));
-
- if (position != -1)
- {
- for (idx = 0; idx <= position; idx++)
- {
- ButtonData *data;
-
- data = BUTTON_DATA (self->button_list->data);
-
- gtk_container_remove (GTK_CONTAINER (self), data->button);
- }
- }
- }
-
- g_object_unref (current_location);
+ /* Do nothing here, the view will set new path if needed. */
g_object_unref (location);
return;
}
--
2.40.0

View File

@ -0,0 +1,37 @@
From 87d2f2cfd61baf813aee204be570172b78159281 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Wed, 14 Jun 2023 12:52:02 +0200
Subject: [PATCH] window-slot: Fix conditions to restore selection when
reloading
Currently, the `nautilus_window_slot_force_reload` function doesn't
preserve selection or position. However, there is a code that should do
it. The code is executed only when `new_content_view != NULL`, but it
is based on the `content_view` property. This seems to be a regression
caused by the commit 9806d70e. Let's fix that condition in order to
ensure that the selection and position are restored.
---
src/nautilus-window-slot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 2bfb3f3ce..8ceac9562 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2376,11 +2376,11 @@ nautilus_window_slot_force_reload (NautilusWindowSlot *self)
g_object_ref (location);
current_pos = NULL;
- if (priv->new_content_view)
+ if (priv->content_view)
{
selection = nautilus_view_get_selection (priv->content_view);
- if (NAUTILUS_IS_FILES_VIEW (priv->new_content_view))
+ if (NAUTILUS_IS_FILES_VIEW (priv->content_view))
{
current_pos = nautilus_files_view_get_first_visible_file (NAUTILUS_FILES_VIEW (priv->content_view));
}
--
2.40.0

View File

@ -0,0 +1,43 @@
From f68481d2d8393f1ba1a9b0a86a1b28b6ac303a63 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Wed, 24 May 2023 13:09:35 +0200
Subject: [PATCH] window-slot: Force reload current location when it reappears
When the currently opened location disappears, nautilus tries to
reopen it thanks to the commit b0e28bc1. However, the
`nautilus_window_slot_open_location_full` function doesn't begin the
location change when the old location is the same as the new one. This
is a problem because the old `NautilusFile` object is marked as gone
and thus monitoring and perhaps some other stuff won't work. Let's use
the `nautilus_window_slot_force_reload` function instead, in this case,
to ensure that the underlying `NautilusFile` is updated.
---
src/nautilus-window-slot.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 811152a21..561b34f12 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -1458,7 +1458,17 @@ viewed_file_changed_callback (NautilusFile *file,
go_to_file = g_file_new_for_path (g_get_home_dir ());
}
- nautilus_window_slot_open_location_full (self, go_to_file, 0, NULL);
+ if (g_file_equal (location, go_to_file))
+ {
+ /* Path gone by time out may have been remounted by
+ * `nautilus_find_existing_uri_in_hierarchy()`.
+ */
+ nautilus_window_slot_force_reload (self);
+ }
+ else
+ {
+ nautilus_window_slot_open_location_full (self, go_to_file, 0, NULL);
+ }
g_object_unref (go_to_file);
g_object_unref (location);
--
2.40.0