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);