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



commit 35b77c9747476dc5223943d200e69a66209622fe
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 8a51f4c..eb03b41 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 5002419..34bf1fc 100644
--- a/tests/delegates/delegates.vala
+++ b/tests/delegates/delegates.vala
@@ -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;
 	}
 }



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