]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix lock statements in classes without private fields
authorJürg Billeter <j@bitron.ch>
Sat, 16 Oct 2010 08:43:19 +0000 (10:43 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 16 Oct 2010 08:43:19 +0000 (10:43 +0200)
Fixes bug 629593.

codegen/valagtypemodule.vala
vala/valaclass.vala

index 6612f86e3b340d27371bd1ad224869bd738be5da..e026bbf3d07621af3598351d0f7a0e6163f7b185 100644 (file)
@@ -382,7 +382,6 @@ public class Vala.GTypeModule : GErrorModule {
                }
 
                bool is_gtypeinstance = !cl.is_compact;
-               bool has_instance_locks = false;
                bool has_class_locks = false;
 
                var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (cl.get_cname ()));
@@ -442,7 +441,7 @@ public class Vala.GTypeModule : GErrorModule {
                                }
 
                                if (f.get_lock_used ()) {
-                                       has_instance_locks = true;
+                                       cl.has_private_fields = true;
                                        // add field for mutex
                                        instance_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (f.name));
                                }
@@ -462,7 +461,7 @@ public class Vala.GTypeModule : GErrorModule {
                foreach (Property prop in cl.get_properties ()) {
                        if (prop.binding == MemberBinding.INSTANCE) {
                                if (prop.get_lock_used ()) {
-                                       has_instance_locks = true;
+                                       cl.has_private_fields = true;
                                        // add field for mutex
                                        instance_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (prop.name));
                                }
@@ -487,7 +486,7 @@ public class Vala.GTypeModule : GErrorModule {
                        }
 
                        /* only add the *Private struct if it is not empty, i.e. we actually have private data */
-                       if (cl.has_private_fields || cl.get_type_parameters ().size > 0 || has_instance_locks) {
+                       if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
                                decl_space.add_type_definition (instance_priv_struct);
                                var macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (cl.get_type_id (), cl.get_cname ());
                                decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
index fd4badd2dcdb840c2f5c2f07bfdfca2bf5a9a557..21b212bb7d95686b5d31f48530e9e371c132affe 100644 (file)
@@ -95,7 +95,7 @@ public class Vala.Class : ObjectTypeSymbol {
        /**
         * Specifies whether this class has private fields.
         */
-       public bool has_private_fields { get; private set; }
+       public bool has_private_fields { get; set; }
        
        /**
         * Specifies whether this class has class fields.