]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gtkmodule: Throw error on [GtkChild] in non-[GtkTemplate] class 75359c3cab2e979d087ce0a19735bf86add33b42
authorTimm Bäder <mail@baedert.org>
Wed, 28 Aug 2013 17:36:07 +0000 (19:36 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Mon, 7 Oct 2013 20:03:39 +0000 (22:03 +0200)
If this happens, the author most probably just forgot to add the
[GtkTemplate] attribute and we throw an error.

codegen/valagtkmodule.vala

index 66139f14d5751c606fae853f952b60f63673dc1d..f3c9a3d41e1b56221921570e410b15de12c36eff 100644 (file)
@@ -199,7 +199,7 @@ public class Vala.GtkModule : GSignalModule {
                base.visit_field (f);
 
                var cl = current_class;
-               if (cl == null || cl.error || !is_gtk_template (cl)) {
+               if (cl == null || cl.error) {
                        return;
                }
 
@@ -207,6 +207,13 @@ public class Vala.GtkModule : GSignalModule {
                        return;
                }
 
+               /* If the field has a [GtkChild] attribute but its class doesn'thave a
+                        [GtkTemplate] attribute, we throw an error */
+               if (!is_gtk_template (cl)) {
+                       Report.error (f.source_reference, "[GtkChild] is only allowed in classes with a [GtkTemplate] attribute");
+                       return;
+               }
+
                push_context (class_init_context);
 
                /* Map ui widget to a class field */