]> 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)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 12 May 2011 13:55:33 +0000 (15:55 +0200)
codegen/valaccodemethodcallmodule.vala
tests/delegates/delegates.vala

index 8a51f4ccb3e986d5e9cbe617d2a4fd0aa0950245..eb03b41783646f48ebd57c125815a3305ea9dab3 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 50024198c5afa244fd9c4ddf352155401fcb9b44..34bf1fcb77e9b301b96785f255ddfe12cbcd20d4 100644 (file)
@@ -74,6 +74,10 @@ class Maman.Bar : Object, Foo {
                var foo = (owned) callback_field;
        }
 
+       static unowned Maman.VoidCallback test_unowned_delegate_return () {
+               return () => {};
+       }
+
        public static int main () {
                stdout.printf ("Delegate Test: 1");
                
@@ -103,6 +107,8 @@ class Maman.Bar : Object, Foo {
 
                test_delegates_interface_method ();
 
+               var baz = test_unowned_delegate_return ();
+
                return 0;
        }
 }