[vala/staging: 2/4] codegen: Use copies of error_variable of catch-clauses for nested usage



commit 765c39c73c3096dd1de984db023763ec13448ef5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jun 6 23:22:41 2018 +0200

    codegen: Use copies of error_variable of catch-clauses for nested usage
    
    Calling visit_local_variable() multiple times on the same instance of a
    LocalVariable causes issues.

 codegen/valagerrormodule.vala | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index d29d09ca1..c10826218 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -353,8 +353,12 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                ccode.open_block ();
 
                if (clause.error_variable != null) {
-                       visit_local_variable (clause.error_variable);
-                       ccode.add_assignment (get_variable_cexpression (get_local_cname 
(clause.error_variable)), get_variable_cexpression ("_inner_error_"));
+                       // use a copy for possible nested usage
+                       var error_variable = new LocalVariable (clause.error_type.copy (), 
clause.variable_name);
+                       error_variable.active = true;
+                       error_variable.checked = true;
+                       visit_local_variable (error_variable);
+                       ccode.add_assignment (get_variable_cexpression (get_local_cname (error_variable)), 
get_variable_cexpression ("_inner_error_"));
                } else {
                        // error object is not used within catch statement, clear it
                        var cclear = new CCodeFunctionCall (new CCodeIdentifier ("g_clear_error"));


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