From 4a7a6067a6437f21831d53aab6d303a0f5c8a305 Mon Sep 17 00:00:00 2001 From: Peter Eisenmann Date: Mon, 7 Aug 2023 20:03:15 +0200 Subject: [PATCH] gtkplacesview: handle empty search queries g_utf8_strdown() does not handle NULL, but setting a new search query to NULL is not needed anyway, so skip setting it. Turn the comparison into an early return to not require nested conditionals. Fixes #3048 --- src/gtk/nautilusgtkplacesview.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c index 9b980fbb50..0e090b14fb 100644 --- a/src/gtk/nautilusgtkplacesview.c +++ b/src/gtk/nautilusgtkplacesview.c @@ -2561,16 +2561,18 @@ nautilus_gtk_places_view_set_search_query (NautilusGtkPlacesView *view, { g_return_if_fail (NAUTILUS_IS_GTK_PLACES_VIEW (view)); - if (g_strcmp0 (view->search_query, query_text) != 0) - { - g_clear_pointer (&view->search_query, g_free); - view->search_query = g_utf8_strdown (query_text, -1); + if (g_strcmp0 (view->search_query, query_text) == 0) + return; - gtk_list_box_invalidate_filter (GTK_LIST_BOX (view->listbox)); - gtk_list_box_invalidate_headers (GTK_LIST_BOX (view->listbox)); + g_clear_pointer (&view->search_query, g_free); - update_view_mode (view); - } + if (query_text != NULL) + view->search_query = g_utf8_strdown (query_text, -1); + + gtk_list_box_invalidate_filter (GTK_LIST_BOX (view->listbox)); + gtk_list_box_invalidate_headers (GTK_LIST_BOX (view->listbox)); + + update_view_mode (view); } /* -- GitLab