]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Use transfer-ownership=none for InitiallyUnowned based constructors
authorMichal Hruby <michal.mhr@gmail.com>
Tue, 12 Jun 2012 11:57:07 +0000 (13:57 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 23 Jun 2012 15:33:31 +0000 (17:33 +0200)
codegen/valagirwriter.vala

index eff97486892fa369223ecde8b3fbe8a24e4aff3a..7a5cacf61d06d476d72ba04d92e0a07b4eaf9fd0 100644 (file)
@@ -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\"");