[folks: 2/3] Only unref a Persona if we actually held a reference to it in the first place



commit ac26a1cbbc562bd2b41b880ac27173a5cd4dabca
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Jul 15 13:00:52 2010 +0100

    Only unref a Persona if we actually held a reference to it in the first place
    
    Since every Individual is notified of changes to the set of Personas in a
    PersonaStore, many of the Personas it's passed won't belong to it. This
    ensures that the Individual only unrefs Personas which belonged to it.

 folks/individual.vala |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index 332ce13..1607a45 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -351,10 +351,12 @@ public class Folks.Individual : Object,
         {
           unowned Persona p = (Persona) data;
 
-          persona_set.remove (p);
-          this._personas.remove (p);
-          /* FIXME: bgo#624249 means GLib.List leaks item references */
-          g_object_unref (p);
+          if (persona_set.remove (p))
+            {
+              this._personas.remove (p);
+              /* FIXME: bgo#624249 means GLib.List leaks item references */
+              g_object_unref (p);
+            }
         });
 
       if (this._personas.length () < 1)



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