From: Timm Bäder Date: Wed, 28 Aug 2013 17:36:07 +0000 (+0200) Subject: gtkmodule: Throw error on [GtkChild] in non-[GtkTemplate] class X-Git-Tag: 0.22.1~15 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fkeep-around%2F75359c3cab2e979d087ce0a19735bf86add33b42;p=thirdparty%2Fvala.git gtkmodule: Throw error on [GtkChild] in non-[GtkTemplate] class If this happens, the author most probably just forgot to add the [GtkTemplate] attribute and we throw an error. --- diff --git a/codegen/valagtkmodule.vala b/codegen/valagtkmodule.vala index 66139f14d..f3c9a3d41 100644 --- a/codegen/valagtkmodule.vala +++ b/codegen/valagtkmodule.vala @@ -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 */