From: Jim Evins Date: Mon, 15 Feb 2010 22:13:14 +0000 (-0500) Subject: Create a default frame if missing from template file X-Git-Tag: glabels-2_2_7~11 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f428dd10c86b1102e96fe76ff0c62d209d6c2923;p=glabels Create a default frame if missing from template file When parsing a template node, if there is no recognized frame node (e.g. Label-rectangle), a default full-page frame with a 1x1 layout is created. This prevents potential crashes if sharing a user '.glabels' directory with future versions of glabels with new frame types, or in the case of typos for hand generated templates. --- diff --git a/libglabels/xml-template.c b/libglabels/xml-template.c index 6f1ae4b8..9ed25cd9 100644 --- a/libglabels/xml-template.c +++ b/libglabels/xml-template.c @@ -289,6 +289,18 @@ lgl_xml_template_parse_template_node (const xmlNodePtr template_node) g_free (description); g_free (paper_id); + /* + * Create a default full-page frame, if a known frame type was not found. + */ + if ( template->frames == NULL ) + { + lglTemplateFrame *frame; + + frame = lgl_template_frame_rect_new ("0", page_width, page_height, 0, 0, 0); + lgl_template_frame_add_layout (frame, lgl_template_layout_new (1, 1, 0, 0, 0, 0)); + lgl_template_add_frame (template, frame); + } + return template; }