From fd0ccfa16cedd5d424a47e78068d78ee448f04f7 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Thu, 6 Mar 2025 13:53:13 -0500 Subject: [PATCH] plug-ins/help: fix thread unnecessarily waiting when locale_parse failed If `gimp_help_locale_parse` failed due to a locale not having a manual available, we always waited for a 10 seconds timeout because we depended on the value of success to decide if we should exit the thread. When the call finishes we should always stop, so add a `done` parameter and depend on that to decide if we can exit instead of using success. --- plug-ins/help/gimphelpdomain.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plug-ins/help/gimphelpdomain.c b/plug-ins/help/gimphelpdomain.c index 53d6d081c4..c87e4e872c 100644 --- a/plug-ins/help/gimphelpdomain.c +++ b/plug-ins/help/gimphelpdomain.c @@ -45,6 +45,7 @@ typedef struct { gboolean *success; + gboolean *done; GimpHelpLocale *locale; const gchar *uri; @@ -242,20 +243,19 @@ gimp_help_domain_map (GimpHelpDomain *domain, /* private functions */ -G_LOCK_DEFINE (success); +G_LOCK_DEFINE (done); static gboolean parse_thread_func (HelpThreadData *data) { - gboolean success = FALSE; - success = gimp_help_locale_parse (data->locale, data->uri, data->domain, - data->progress, data->cancellable, data->error); - G_LOCK (success); - *data->success = success; - G_UNLOCK (success); + *data->success = gimp_help_locale_parse (data->locale, data->uri, data->domain, + data->progress, data->cancellable, data->error); + G_LOCK (done); + *data->done = TRUE; + G_UNLOCK (done); - return success; + return *data->success; } static gboolean @@ -269,6 +269,7 @@ domain_locale_parse (GimpHelpDomain *domain, GThread *thread; GTimer *timer; gboolean success = FALSE; + gboolean done = FALSE; HelpThreadData data; g_return_val_if_fail (domain != NULL, FALSE); @@ -280,6 +281,7 @@ domain_locale_parse (GimpHelpDomain *domain, timer = g_timer_new (); cancellable = g_cancellable_new (); + data.done = &done; data.success = &success; data.locale = locale; data.uri = uri; @@ -293,9 +295,9 @@ domain_locale_parse (GimpHelpDomain *domain, { gboolean exit; - G_LOCK (success); - exit = success; - G_UNLOCK (success); + G_LOCK (done); + exit = *data.done; + G_UNLOCK (done); if (! exit && g_timer_elapsed (timer, NULL) > 10.0) {