app: unref async when removing last callback if idle is pending

In gimp_async_remove_callback(), if removing the last callback
while the callback idle-source is already pending, cancel the idle
source and unref the async object (the async is reffed when adding
the idle source.)
This commit is contained in:
Ell 2018-11-30 03:09:21 -05:00
parent 4dd3e2197a
commit a779dd3849
1 changed files with 13 additions and 1 deletions

View File

@ -467,7 +467,8 @@ gimp_async_remove_callback (GimpAsync *async,
GimpAsyncCallback callback, GimpAsyncCallback callback,
gpointer data) gpointer data)
{ {
GList *iter; GList *iter;
gboolean unref_async = FALSE;
g_return_if_fail (GIMP_IS_ASYNC (async)); g_return_if_fail (GIMP_IS_ASYNC (async));
g_return_if_fail (callback != NULL); g_return_if_fail (callback != NULL);
@ -492,7 +493,18 @@ gimp_async_remove_callback (GimpAsync *async,
iter = next; iter = next;
} }
if (g_queue_is_empty (&async->priv->callbacks) && async->priv->idle_id)
{
g_source_remove (async->priv->idle_id);
async->priv->idle_id = 0;
unref_async = TRUE;
}
g_mutex_unlock (&async->priv->mutex); g_mutex_unlock (&async->priv->mutex);
if (unref_async)
g_object_unref (async);
} }
/* checks if 'async' is in the "stopped" state. /* checks if 'async' is in the "stopped" state.