mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
files-view: Ensure ununsed search query is cleared
If the location changes away from a search directory (other than by toggling the slot.search-visible action) the view keeps holding a reference to the search query instance. This can be picked up by global search later, which then reuses an old query unexpectedly. The simplest way to reproduce this bug is to type to search, then select a different location from the sidebar, then click the global search button. Let's clear the query whenever the location changes to a non-search directory. Also avoid property notifications if it was already NULL. Since the tight relation between between set_search_query() and location loading is easy to miss and get wrong, also add a few comments at relevant places where its called.
This commit is contained in:
parent
c509a91a49
commit
131f363066
|
@ -3750,6 +3750,11 @@ nautilus_files_view_set_location (NautilusView *view,
|
|||
{
|
||||
/* Regular case */
|
||||
load_directory (NAUTILUS_FILES_VIEW (view), directory);
|
||||
|
||||
/* Ensure we don't keep carrying old queries on. This must be called
|
||||
* after load_directory() is called for the new directory, otherwise it
|
||||
* could try to load the existing search query's base directory. */
|
||||
nautilus_view_set_search_query (view, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9252,8 +9257,10 @@ nautilus_files_view_set_search_query (NautilusView *view,
|
|||
|
||||
priv = nautilus_files_view_get_instance_private (files_view);
|
||||
|
||||
g_set_object (&priv->search_query, query);
|
||||
g_object_notify (G_OBJECT (view), "search-query");
|
||||
if (g_set_object (&priv->search_query, query))
|
||||
{
|
||||
g_object_notify (G_OBJECT (view), "search-query");
|
||||
}
|
||||
|
||||
if (!nautilus_query_is_empty (query))
|
||||
{
|
||||
|
|
|
@ -414,6 +414,7 @@ query_editor_changed_callback (NautilusQueryEditor *editor,
|
|||
|
||||
view = nautilus_window_slot_get_current_view (self);
|
||||
|
||||
/* Setting search query may cause the view to load a new location. */
|
||||
nautilus_view_set_search_query (view, query);
|
||||
nautilus_window_slot_set_location (self, nautilus_view_get_location (view));
|
||||
}
|
||||
|
@ -439,7 +440,12 @@ hide_query_editor (NautilusWindowSlot *self)
|
|||
* revealed in the unfiltered folder view. */
|
||||
selection = nautilus_view_get_selection (view);
|
||||
|
||||
/* Now that we have saved the search, clear the view's query. The view
|
||||
* will immediately clear its model model and load the previous location
|
||||
*/
|
||||
nautilus_view_set_search_query (view, NULL);
|
||||
|
||||
/* The view location has changed, update the slot location. */
|
||||
nautilus_window_slot_set_location (self, nautilus_view_get_location (view));
|
||||
nautilus_view_set_selection (view, selection);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue