Don't do manual memory management for libsocialweb Contact structs
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 12 Mar 2013 17:06:31 +0000 (17:06 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 13 Mar 2013 12:27:17 +0000 (12:27 +0000)
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

index 37b4b7d..3abf357 100644 (file)
@@ -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;
     }
 
   /**