Commit ae800a34 authored by Johan Dahlin's avatar Johan Dahlin

Set an error if we encounter properties without values set (#451303,

    * 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)


svn path=/trunk/; revision=18252
parent 1d2955bc
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.
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment