[gimp/wip/animation: 143/145] plug-ins: better check for queue existence in the idle.



commit 492c3e5cb091c4c101393be970e3bde1316f624a
Author: Jehan <jehan girinstud io>
Date:   Mon Jul 17 12:14:36 2017 +0200

    plug-ins: better check for queue existence in the idle.
    
    When finalizing the animation renderer, the idle may still live slightly
    longer after the queue has been freed. I check first for the priv
    member, because for some reason, I had segfaults sometimes when shutting
    down the plugin immediately after start, though I don't see how this
    could not be present at the time the idle runs; yet it was so.

 plug-ins/animation-play/core/animation-renderer.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-renderer.c 
b/plug-ins/animation-play/core/animation-renderer.c
index ec4955a..b6e664c 100644
--- a/plug-ins/animation-play/core/animation-renderer.c
+++ b/plug-ins/animation-play/core/animation-renderer.c
@@ -171,6 +171,7 @@ animation_renderer_finalize (GObject *object)
   /* Clean remaining data. */
   if (renderer->priv->idle_id)
     g_source_remove (renderer->priv->idle_id);
+  renderer->priv->idle_id = 0;
   g_mutex_lock (&renderer->priv->lock);
   for (i = 0; i < animation_get_duration (animation); i++)
     {
@@ -183,7 +184,9 @@ animation_renderer_finalize (GObject *object)
   g_free (renderer->priv->hashes);
 
   g_async_queue_unref (renderer->priv->queue);
+  renderer->priv->queue = NULL;
   g_async_queue_unref (renderer->priv->ack_queue);
+  renderer->priv->ack_queue = NULL;
   g_hash_table_destroy (renderer->priv->cache_table);
   g_mutex_unlock (&renderer->priv->lock);
   g_mutex_clear (&renderer->priv->lock);
@@ -321,7 +324,7 @@ static gboolean
 animation_renderer_idle_update (AnimationRenderer *renderer)
 {
   gpointer p;
-  gboolean retval;
+  gboolean retval = G_SOURCE_CONTINUE;;
 
   while ((p = g_async_queue_try_pop (renderer->priv->ack_queue)))
     {
@@ -335,16 +338,13 @@ animation_renderer_idle_update (AnimationRenderer *renderer)
   /* If nothing is being rendered (negative queue length, meaning the
    * renderer is waiting), nor is there anything in the ACK queue, just
    * stop the idle source. */
-  if (g_async_queue_length (renderer->priv->queue) < 0 &&
+  if (renderer->priv && renderer->priv->queue &&
+      g_async_queue_length (renderer->priv->queue) < 0 &&
       g_async_queue_length (renderer->priv->ack_queue) == 0)
     {
       retval = G_SOURCE_REMOVE;
       renderer->priv->idle_id = 0;
     }
-  else
-    {
-      retval = G_SOURCE_CONTINUE;
-    }
 
   return retval;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]