From 019c232565740e99cdd45edf259f31c3821c7778 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sun, 21 Jun 2015 11:42:43 +0300 Subject: [PATCH] Settings: Fix loading of wallpaper previews (Bug #11892) For some users they end up without wallpapers being loaded even though the thumbnailer creates the thumbnails. This patch makes it so the preview thread doesn't block waiting for new previews and instead exits when the queue is empty so the thread and queue can be better tracked. --- settings/main.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/settings/main.c b/settings/main.c index 312806a..9bd061a 100644 --- a/settings/main.c +++ b/settings/main.c @@ -276,10 +276,23 @@ xfdesktop_settings_create_previews(gpointer data) while(panel->preview_queue != NULL) { PreviewData *pdata = NULL; - /* Block and wait for another preview to create */ - pdata = g_async_queue_pop(panel->preview_queue); + /* try to pull another preview */ + pdata = g_async_queue_try_pop(panel->preview_queue); - xfdesktop_settings_do_single_preview(pdata); + if(pdata != NULL) { + xfdesktop_settings_do_single_preview(pdata); + } else { + /* Nothing left, remove the queue, we're done with it */ + g_async_queue_unref(panel->preview_queue); + panel->preview_queue = NULL; + } + } + + /* Remove the preview thread */ + if(panel->preview_thread != NULL) { + g_thread_unref (panel->preview_thread); + panel->preview_thread = NULL; + g_thread_exit (0); } return NULL; @@ -295,6 +308,7 @@ xfdesktop_settings_add_file_to_queue(AppearancePanel *panel, PreviewData *pdata) /* Create the queue if it doesn't exist */ if(panel->preview_queue == NULL) { + XF_DEBUG("creating preview queue"); panel->preview_queue = g_async_queue_new_full(xfdesktop_settings_free_pdata); } @@ -302,6 +316,7 @@ xfdesktop_settings_add_file_to_queue(AppearancePanel *panel, PreviewData *pdata) /* Create the thread if it doesn't exist */ if(panel->preview_thread == NULL) { + XF_DEBUG("creating preview thread"); #if GLIB_CHECK_VERSION(2, 32, 0) panel->preview_thread = g_thread_try_new("create_previews", xfdesktop_settings_create_previews, @@ -376,6 +391,7 @@ xfdesktop_settings_queue_preview(GtkTreeModel *model, pdata->model = g_object_ref(G_OBJECT(model)); pdata->iter = gtk_tree_iter_copy(iter); + XF_DEBUG("Thumbnailing failed, adding %s manually.", filename); xfdesktop_settings_add_file_to_queue(panel, pdata); } @@ -1088,16 +1104,19 @@ cb_xfdesktop_spin_icon_size_changed(GtkSpinButton *button, static void xfdesktop_settings_stop_image_loading(AppearancePanel *panel) { + XF_DEBUG("xfdesktop_settings_stop_image_loading"); /* stop any thumbnailing in progress */ xfdesktop_thumbnailer_dequeue_all_thumbnails(panel->thumbnailer); /* Remove the previews in the message queue */ if(panel->preview_queue != NULL) { + XF_DEBUG("removing items from preview queue"); while(g_async_queue_length(panel->preview_queue) > 0) { gpointer data = g_async_queue_try_pop(panel->preview_queue); if(data) xfdesktop_settings_free_pdata(data); } + /* the preview queue will clean itself up */ } /* Cancel any file enumeration that's running */ -- 2.4.4