]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't spit out critical when returning unowned delegate
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 12 May 2011 13:53:26 +0000 (15:53 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 29 May 2011 10:56:00 +0000 (12:56 +0200)
codegen/valaccodemethodcallmodule.vala
tests/delegates/delegates.vala

index f7abf5ebd9a32714a3ee1af1d285bb9dadc1747f..7e384f3247a5067af3fae09b7f65f5d1828f3a7b 100644 (file)
@@ -518,7 +518,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                        out_arg_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
 
                                        set_delegate_target_destroy_notify (expr, temp_ref);
+                               } else {
+                                       set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
                                }
+                       } else {
+                               set_delegate_target (expr, new CCodeConstant ("NULL"));
                        }
                }
 
index e80fd3fe83f73a7b33791896289d51ca84416771..ca5a98ac771506469bea6bdbd63139f22daa70ef 100644 (file)
@@ -68,6 +68,10 @@ class Maman.Bar : Object, Foo {
                call_instance_delegate (bar.foo_method);
        }
 
+       static unowned Maman.VoidCallback test_unowned_delegate_return () {
+               return () => {};
+       }
+
        public static int main () {
                stdout.printf ("Delegate Test: 1");
                
@@ -97,6 +101,8 @@ class Maman.Bar : Object, Foo {
 
                test_delegates_interface_method ();
 
+               var baz = test_unowned_delegate_return ();
+
                return 0;
        }
 }