[vala/0.16] girwriter: Use transfer-ownership=none for InitiallyUnowned based constructors



commit 677b7be06db5dda437f4808760341b583c2390fc
Author: Michal Hruby <michal mhr gmail com>
Date:   Tue Jun 12 13:57:07 2012 +0200

    girwriter: Use transfer-ownership=none for InitiallyUnowned based constructors

 codegen/valagirwriter.vala |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index eff9748..7a5cacf 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -109,6 +109,7 @@ public class Vala.GIRWriter : CodeVisitor {
 	int indent;
 
 	private TypeSymbol gobject_type;
+	private TypeSymbol ginitiallyunowned_type;
 
 	private struct GIRNamespace {
 		public GIRNamespace (string ns, string version) {
@@ -149,6 +150,7 @@ public class Vala.GIRWriter : CodeVisitor {
 		var root_symbol = context.root;
 		var glib_ns = root_symbol.scope.lookup ("GLib");
 		gobject_type = (TypeSymbol) glib_ns.scope.lookup ("Object");
+		ginitiallyunowned_type = (TypeSymbol) glib_ns.scope.lookup ("InitiallyUnowned");
 
 		write_package (package);
 
@@ -1156,7 +1158,7 @@ public class Vala.GIRWriter : CodeVisitor {
 
 		DelegateType delegate_type = type as DelegateType;
 
-		if ((type.value_owned && delegate_type == null) || constructor) {
+		if ((type.value_owned && delegate_type == null) || (constructor && !type.data_type.is_subtype_of (ginitiallyunowned_type))) {
 			buffer.append_printf (" transfer-ownership=\"full\"");
 		} else {
 			buffer.append_printf (" transfer-ownership=\"none\"");



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