[vala/0.12] codegen: Don't spit out critical when returning unowned delegate



commit 60aa75e904c59a4f22502af3d644ab686a5f1d64
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu May 12 15:53:26 2011 +0200

    codegen: Don't spit out critical when returning unowned delegate

 codegen/valaccodemethodcallmodule.vala |    4 ++++
 tests/delegates/delegates.vala         |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index f7abf5e..7e384f3 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -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"));
 			}
 		}
 
diff --git a/tests/delegates/delegates.vala b/tests/delegates/delegates.vala
index e80fd3f..ca5a98a 100644
--- a/tests/delegates/delegates.vala
+++ b/tests/delegates/delegates.vala
@@ -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;
 	}
 }



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