From 1d4ea5dac3f02a9558d4cf46198bd50a7b6098a4 Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Fri, 29 May 2026 11:15:07 +0200 Subject: [PATCH] filechooser: skip stale thumbnail queue entries --- gtk/gtkfilechooserdefault.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index c6dc58f95..1bf79db86 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1569,6 +1569,27 @@ thumbnail_worker_start (GtkFileChooserDefault *impl, return TRUE; } +static gboolean +thumbnail_queue_file_still_needed (GtkFileChooserDefault *impl, + GFile *file) +{ + GtkFileSystemModel *model; + GtkTreeIter iter; + GFileInfo *info; + + if (!impl->current_model || !GTK_IS_FILE_SYSTEM_MODEL (impl->current_model)) + return FALSE; + + model = GTK_FILE_SYSTEM_MODEL (impl->current_model); + + if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file)) + return FALSE; + + info = _gtk_file_system_model_get_info (model, &iter); + + return thumbnail_queue_should_enqueue (impl, file, info); +} + static gboolean thumbnail_queue_idle_cb (gpointer data) { @@ -1590,6 +1611,17 @@ thumbnail_queue_idle_cb (gpointer data) return FALSE; } + if (!thumbnail_queue_file_still_needed (impl, file)) + { + g_object_unref (file); + impl->thumbnail_worker_running = FALSE; + + if (impl->thumbnail_queue) + thumbnail_queue_schedule (impl); + + return FALSE; + } + if (!thumbnail_worker_start (impl, file)) { g_object_unref (file);