fix iteration over collections passed by ref parameter using foreach,
authorJuerg Billeter <j@bitron.ch>
Fri, 18 Jan 2008 16:59:12 +0000 (16:59 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 18 Jan 2008 16:59:12 +0000 (16:59 +0000)
2008-01-18  Juerg Billeter  <j@bitron.ch>

* gobject/valaccodegenerator.vala: fix iteration over collections
  passed by ref parameter using foreach,
  patch by Hans Vercammen, fixes bug 510419

svn path=/trunk/; revision=852

ChangeLog
gobject/valaccodegenerator.vala

index bf7b3b1..d99b46b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-01-18  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valaccodegenerator.vala: fix iteration over collections
+         passed by ref parameter using foreach,
+         patch by Hans Vercammen, fixes bug 510419
+
+2008-01-18  Jürg Billeter  <j@bitron.ch>
+
        * vala/valanulltype.vala, vala/valasemanticanalyzer.vala: simplify
          conditional expression type analysis, fixes crash
 
index 7fb0f9c..453e0e2 100644 (file)
@@ -1520,7 +1520,10 @@ public class Vala.CCodeGenerator : CodeGenerator {
                cblock.add_statement (cfrag);
                
                var collection_backup = stmt.collection_variable_declarator;
-               var ccoldecl = new CCodeDeclaration (collection_backup.type_reference.get_cname ());
+               var collection_type = collection_backup.type_reference.copy ();
+               collection_type.is_ref = false;
+               collection_type.is_out = false;
+               var ccoldecl = new CCodeDeclaration (collection_type.get_cname ());
                var ccolvardecl = new CCodeVariableDeclarator.with_initializer (collection_backup.name, (CCodeExpression) stmt.collection.ccodenode);
                ccolvardecl.line = cblock.line;
                ccoldecl.add_declarator (ccolvardecl);
@@ -1542,7 +1545,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        if (array_len is CCodeConstant) {
                                var it_name = "%s_it".printf (stmt.variable_name);
                        
-                               var citdecl = new CCodeDeclaration (stmt.collection.static_type.get_cname ());
+                               var citdecl = new CCodeDeclaration (collection_type.get_cname ());
                                citdecl.add_declarator (new CCodeVariableDeclarator (it_name));
                                cblock.add_statement (citdecl);
                                
@@ -1640,7 +1643,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
                           stmt.collection.static_type.data_type == gslist_type) {
                        var it_name = "%s_it".printf (stmt.variable_name);
                
-                       var citdecl = new CCodeDeclaration (stmt.collection.static_type.get_cname ());
+                       var citdecl = new CCodeDeclaration (collection_type.get_cname ());
                        var citvardecl = new CCodeVariableDeclarator (it_name);
                        citvardecl.line = cblock.line;
                        citdecl.add_declarator (citvardecl);