summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--gtk/gtkbuilder.h3
-rw-r--r--gtk/gtkbuilderparser.c24
-rw-r--r--tests/buildertest.c7
4 files changed, 39 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f6465ac673..d62764592f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-06-26 Johan Dahlin <jdahlin@async.com.br>
+ * gtk/gtkbuilder.h (enum):
+ * gtk/gtkbuilderparser.c (end_element):
+ * tests/buildertest.c (test_parser):
+ Set an error if we encounter properties without values set
+ (#451303, Philip Withnall)
+
* demos/gtk-demo/builder.c (do_builder): Connect the
destroy signal in the example instead of the ui file.
Also set the screen and title of the window.
diff --git a/gtk/gtkbuilder.h b/gtk/gtkbuilder.h
index 767d7220ad..36348b25ac 100644
--- a/gtk/gtkbuilder.h
+++ b/gtk/gtkbuilder.h
@@ -43,7 +43,8 @@ typedef enum
GTK_BUILDER_ERROR_UNHANDLED_TAG,
GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
- GTK_BUILDER_ERROR_INVALID_TAG
+ GTK_BUILDER_ERROR_INVALID_TAG,
+ GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE
} GtkBuilderError;
GQuark gtk_builder_error_quark (void);
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 25b3479946..ea2df67e64 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -139,6 +139,24 @@ error_invalid_tag (ParserData *data,
line_number, char_number, tag);
}
+static void
+error_missing_property_value (ParserData *data,
+ GError **error)
+{
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position (data->ctx,
+ &line_number,
+ &char_number);
+
+ g_set_error (error,
+ GTK_BUILDER_ERROR,
+ GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
+ "%s:%d:%d <property> must have a value set",
+ data->filename,
+ line_number, char_number);
+}
+
static GObject *
builder_construct (ParserData *data,
ObjectInfo *object_info)
@@ -707,6 +725,12 @@ end_element (GMarkupParseContext *context,
PropertyInfo *prop_info = state_pop_info (data, PropertyInfo);
CommonInfo *info = state_peek_info (data, CommonInfo);
+ if (!prop_info->data)
+ {
+ error_missing_property_value (data, error);
+ return;
+ }
+
/* Normal properties */
if (strcmp (info->tag.name, "object") == 0)
{
diff --git a/tests/buildertest.c b/tests/buildertest.c
index 3c6ab29b17..3367bdcd1f 100644
--- a/tests/buildertest.c
+++ b/tests/buildertest.c
@@ -72,6 +72,13 @@ gboolean test_parser (void)
g_return_val_if_fail (strcmp (error->message, "<input>:1:74 'object' is not a valid tag here") == 0, FALSE);
g_error_free (error);
+ error = NULL;
+ gtk_builder_add_from_string (builder, "<interface><object class=\"GtkWindow\" id=\"a\"><property name=\"type\"/></object></interface>", -1, &error);
+ g_assert (error != NULL);
+ g_return_val_if_fail (strcmp (error->message, "<input>:1:67 <property> must have a value set") == 0, FALSE);
+ g_error_free (error);
+
+
return TRUE;
}