[vala] gtkmodule: Throw error on [GtkChild] in non-[GtkTemplate] class



commit 75359c3cab2e979d087ce0a19735bf86add33b42
Author: Timm Bäder <mail baedert org>
Date:   Wed Aug 28 19:36:07 2013 +0200

    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 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagtkmodule.vala b/codegen/valagtkmodule.vala
index 66139f1..f3c9a3d 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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]