]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always call _finish() after yield
authorLuca Bruno <lucabru@src.gnome.org>
Tue, 22 Mar 2011 20:53:22 +0000 (21:53 +0100)
committerJürg Billeter <j@bitron.ch>
Wed, 23 Mar 2011 20:59:47 +0000 (21:59 +0100)
Fixes bug 645606.

codegen/valaccodemethodcallmodule.vala

index 87a083f51dfcfb5ae98b2cb0e7894c371f6c6651..f7abf5ebd9a32714a3ee1af1d285bb9dadc1747f 100644 (file)
@@ -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 ();