[gnome-photos/wip/rishi/cancel-async: 4/6] embed: Don't leak self when load_show_id is removed before the timeout



commit e88a952b07f9ed3bd7d4016e68983b12300a57a8
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 18 19:41:51 2016 +0100

    embed: Don't leak self when load_show_id is removed before the timeout
    
    We were dropping the reference only in the timeout handler. That means
    we were leaking it if the source was removed before the handler got
    run. Tying it more tightly to the GSource with a GDestroyNotify solves
    this problem.

 src/photos-embed.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 4a4c5ab..9cb7c83 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -343,7 +343,6 @@ photos_embed_load_show_timeout (gpointer user_data)
 
   self->load_show_id = 0;
   photos_spinner_box_start (PHOTOS_SPINNER_BOX (self->spinner_box));
-  g_object_unref (self);
   return G_SOURCE_REMOVE;
 }
 
@@ -352,7 +351,11 @@ static void
 photos_embed_load_started (PhotosEmbed *self, PhotosBaseItem *item)
 {
   photos_embed_clear_load_timer (self);
-  self->load_show_id = g_timeout_add (400, photos_embed_load_show_timeout, g_object_ref (self));
+  self->load_show_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
+                                           400,
+                                           photos_embed_load_show_timeout,
+                                           g_object_ref (self),
+                                           g_object_unref);
 }
 
 


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