+2009-01-09 Jürg Billeter <j@bitron.ch>
+
+ * gobject/valaccodememberaccessmodule.vala:
+
+ Do not free values returned via g_object_get prematurely, require
+ properties without accessor methods to return an owned value,
+ fixes bug 559644
+
2009-01-09 Jürg Billeter <j@bitron.ch>
* vala/valaunaryexpression.vala:
ccall.add_argument (pub_inst);
}
- // Property acesses to real struct types are handeled different to other properties.
- // They are returned as out parameter.
+ // Property access to real struct types is handled differently
+ // The value is returned by out parameter
if (base_property.property_type.is_real_struct_type ()) {
var ccomma = new CCodeCommaExpression ();
var temp_var = get_temp_variable (base_property.property_type);
}
} else {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_object_get"));
-
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT"));
- ccast.add_argument (pub_inst);
- ccall.add_argument (ccast);
+ ccall.add_argument (pub_inst);
// 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;
+ // therefore, property getters of properties
+ // without accessor methods need to be marked as owned
- // we need a temporary variable to save the property value
+ var ccomma = new CCodeCommaExpression ();
var temp_var = get_temp_variable (expr.value_type);
- temp_vars.insert (0, temp_var);
-
- if (requires_destroy (temp_type)) {
- temp_ref_vars.insert (0, temp_var);
- }
-
var ctemp = new CCodeIdentifier (temp_var.name);
+ temp_vars.add (temp_var);
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
-
-
ccall.add_argument (new CCodeConstant ("NULL"));
-
- var ccomma = new CCodeCommaExpression ();
ccomma.append_expression (ccall);
ccomma.append_expression (ctemp);
expr.ccodenode = ccomma;