From 75359c3cab2e979d087ce0a19735bf86add33b42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 28 Aug 2013 19:36:07 +0200 Subject: [PATCH] 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. --- codegen/valagtkmodule.vala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 */ -- 2.47.2