From af6fb83a51821cc980196418e464afca5058cb00 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 8 Mar 2024 09:38:15 +0100 Subject: [PATCH] [View] Work around GThreadPool 1 pointer bug. * Also fix typo in icon fetcher. --- source/rofi-icon-fetcher.c | 2 +- source/view.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 1fd37004..ef19bf5f 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -94,7 +94,7 @@ static void rofi_icon_fetch_entry_free(gpointer data); IconFetcher *rofi_icon_fetcher_data = NULL; static void rofi_icon_fetch_thread_pool_entry_remove(gpointer data) { - IconFetcherNameEntry *entry = (IconFetcherNameEntry *)data; + IconFetcherEntry *entry = (IconFetcherEntry *)data; // Mark it in a way it should be re-fetched on next query? } static void rofi_icon_fetch_entry_free(gpointer data) { diff --git a/source/view.c b/source/view.c index 3e463a67..aac8c22e 100644 --- a/source/view.c +++ b/source/view.c @@ -2653,6 +2653,15 @@ static int rofi_thread_workers_sort(gconstpointer a, gconstpointer b, static void rofi_thread_pool_state_free(gpointer data) { if (data) { + // This is a weirdness from glib that should not happen. + // It pushes in a 1 to msg sleeping threads to wake up. + // This should be removed from queue to avoid hitting this method. + // In practice, we still hit it (and crash) + if (GPOINTER_TO_UINT(data) == 1) { + // Ignore this entry. + g_debug("Glib thread-pool bug, received pointer with value 1."); + return; + } thread_state *ts = (thread_state *)data; if (ts->free) { ts->free(data);