vala r1838 - in trunk: . gobject



Author: juergbi
Date: Wed Oct 15 09:37:31 2008
New Revision: 1838
URL: http://svn.gnome.org/viewvc/vala?rev=1838&view=rev

Log:
2008-10-15  JÃrg Billeter  <j bitron ch>

	* gobject/valaccodememberaccessbinding.vala:

	Fix memory leak when using GObject properties without accessors


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodememberaccessbinding.vala

Modified: trunk/gobject/valaccodememberaccessbinding.vala
==============================================================================
--- trunk/gobject/valaccodememberaccessbinding.vala	(original)
+++ trunk/gobject/valaccodememberaccessbinding.vala	Wed Oct 15 09:37:31 2008
@@ -206,15 +206,22 @@
 				var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT"));
 				ccast.add_argument (pub_inst);
 				ccall.add_argument (ccast);
-				
+
 				// property name is second argument of g_object_get
 				ccall.add_argument (prop.get_canonical_cconstant ());
-				
-				
+
+				// g_object_get always returns owned values
+				var temp_type = expr.value_type.copy ();
+				temp_type.value_owned = true;
+
 				// we need a temporary variable to save the property value
 				var temp_var = codegen.get_temp_variable (expr.value_type);
 				codegen.temp_vars.insert (0, temp_var);
 
+				if (codegen.requires_destroy (temp_type)) {
+					codegen.temp_ref_vars.insert (0, temp_var);
+				}
+
 				var ctemp = new CCodeIdentifier (temp_var.name);
 				ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
 				



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