From ced88fd0de4aedb537552561582875b427081eeb Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 9 Jun 2009 10:54:22 +0200 Subject: [PATCH] =?UTF-8?q?Bug=20585189=20=E2=80=93=20g=5Fcancellable=5Fre?= =?UTF-8?q?set()=20must=20be=20called=20in=20same=20thread=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as g_cancellable_cancel() Rework a g_critical() that would (rarely) trigger when _reset() was called in a thread different from _cancel() by making _reset() wait for the cancel function to be finished the same way g_cancellable_disconnect() uses. --- gio/gcancellable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/gcancellable.c b/gio/gcancellable.c index e54d6c897..19326b50d 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -327,11 +327,11 @@ g_cancellable_reset (GCancellable *cancellable) G_LOCK(cancellable); - if (cancellable->cancelled_running) + while (cancellable->cancelled_running) { - g_critical ("Can't reset a cancellable during an active operation"); - G_UNLOCK(cancellable); - return; + cancellable->cancelled_running_waiting = TRUE; + g_cond_wait (cancellable_cond, + g_static_mutex_get_mutex (& G_LOCK_NAME (cancellable))); } if (cancellable->cancelled)