[vala] codegen: Always call _finish() after yield



commit 4e4835ba77214f586080cf222fc9d161a28083c7
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Mar 22 21:53:22 2011 +0100

    codegen: Always call _finish() after yield
    
    Fixes bug 645606.

 codegen/valaccodemethodcallmodule.vala |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 87a083f..f7abf5e 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -618,16 +618,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			}
 		}
 
-		if (return_result_via_out_param) {
-			var temp_var = get_temp_variable (itype.get_return_type ());
-			var temp_ref = get_variable_cexpression (temp_var.name);
-
-			emit_temp_var (temp_var);
-
-			out_arg_map.set (get_param_pos (-3), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+		CCodeExpression out_param_ref = null;
 
-			ccode.add_expression (ccall_expr);
-			ccall_expr = temp_ref;
+		if (return_result_via_out_param) {
+			var out_param_var = get_temp_variable (itype.get_return_type ());
+			out_param_ref = get_variable_cexpression (out_param_var.name);
+			emit_temp_var (out_param_var);
+			out_arg_map.set (get_param_pos (-3), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, out_param_ref));
 		}
 
 		// append C arguments in the right order
@@ -670,10 +667,6 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			}
 		}
 
-		if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) {
-			ccall_expr = new CCodeAssignment (instance, ccall_expr);
-		}
-
 		if (expr.is_yield_expression) {
 			// set state before calling async function to support immediate callbacks
 			int state = next_coroutine_state++;
@@ -684,6 +677,15 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			ccode.add_label ("_state_%d".printf (state));
 		}
 
+		if (return_result_via_out_param) {
+			ccode.add_expression (ccall_expr);
+			ccall_expr = out_param_ref;
+		}
+
+		if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) {
+			ccall_expr = new CCodeAssignment (instance, ccall_expr);
+		}
+
 		if (m is ArrayResizeMethod) {
 			// FIXME: size expression must not be evaluated twice at runtime (potential side effects)
 			Iterator<Expression> arg_it = expr.get_argument_list ().iterator ();



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