[folks] Don't do manual memory management for libsocialweb Contact structs



commit 89481c9dac3d4a528781c090463045bba691ab31
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Tue Mar 12 17:06:31 2013 +0000

    Don't do manual memory management for libsocialweb Contact structs
    
    GObject (and hence Vala) already knows how to memory-manage a Contact,
    because it's a boxed type. Trying to do our own memory-management
    anyway results in an occasional (50%?) double-free and crash.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=695719
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Philip Withnall <philip tecnocode co uk>

 backends/libsocialweb/lib/swf-persona.vala |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
---
diff --git a/backends/libsocialweb/lib/swf-persona.vala b/backends/libsocialweb/lib/swf-persona.vala
index 37b4b7d..3abf357 100644
--- a/backends/libsocialweb/lib/swf-persona.vala
+++ b/backends/libsocialweb/lib/swf-persona.vala
@@ -180,7 +180,7 @@ public class Swf.Persona : Folks.Persona,
       set { this.change_web_service_addresses.begin (value); }
     }
 
-  private Contact _lsw_contact;
+  private Contact? _lsw_contact = null;
 
   /**
    * The Contact from libsocialweb
@@ -190,11 +190,7 @@ public class Swf.Persona : Folks.Persona,
       get { return this._lsw_contact; }
       construct
         {
-          if (_lsw_contact != null && _lsw_contact != value)
-            {
-              _lsw_contact.unref ();
-            }
-          this._lsw_contact = value.ref ();
+          this._lsw_contact = value;
         }
     }
 
@@ -306,8 +302,6 @@ public class Swf.Persona : Folks.Persona,
   ~Persona ()
     {
       debug ("Destroying Sw.Persona '%s': %p", this.uid, this);
-      this._lsw_contact.unref ();
-      this._lsw_contact = null;
     }
 
   /**


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