]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix deserialiation of hash tables
authorRico Tzschichholz <ricotz@t-online.de>
Mon, 22 Oct 2012 13:03:18 +0000 (15:03 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 11 Mar 2019 12:52:38 +0000 (13:52 +0100)
codegen/valagvarianttransformer.vala
vala/valacodetransformer.vala

index 8d0f1b9236412f271676c18f2135532457543fb5..6a77ea22d5dd8372f6ab5b881d7e2cde97cbe60c 100644 (file)
@@ -405,13 +405,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        var value_type = type_args.get (1);
 
                        Expression hash_table_new;
+                       var hash_table_new_type = copy_type (type, true, false);
                        if (key_type.data_type == context.analyzer.string_type.data_type) {
-                               hash_table_new = expression (@"new $type (GLib.str_hash, GLib.str_equal)");
+                               hash_table_new = expression (@"new $hash_table_new_type (GLib.str_hash, GLib.str_equal)");
                        } else {
-                               hash_table_new = expression (@"new $type (GLib.direct_hash, GLib.direct_equal)");
+                               hash_table_new = expression (@"new $hash_table_new_type (GLib.direct_hash, GLib.direct_equal)");
                        }
 
-                       var hash_table = b.add_temp_declaration (copy_type (type, true), hash_table_new);
+                       var hash_table = b.add_temp_declaration (hash_table_new_type, hash_table_new);
                        var new_variant = b.add_temp_declaration (data_type ("GLib.Variant"));
 
                        b.open_while (expression (@"($new_variant = $iterator.next_value ()) != null"));
index 7e6001a081c663438576d5b1b9e1548663b2698e..8ff5b80821313b9585be6fb0f880104766046aff 100644 (file)
@@ -58,9 +58,14 @@ public class Vala.CodeTransformer : CodeVisitor {
                }
        }
 
-       public static DataType copy_type (DataType type, bool value_owned) {
+       public static DataType copy_type (DataType type, bool? value_owned = null, bool? nullable = null) {
                var ret = type.copy ();
-               ret.value_owned = value_owned;
+               if (value_owned != null) {
+                       ret.value_owned = value_owned;
+               }
+               if (nullable != null) {
+                       ret.nullable = nullable;
+               }
                return ret;
        }