From f428dd10c86b1102e96fe76ff0c62d209d6c2923 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 15 Feb 2010 17:13:14 -0500 Subject: [PATCH] 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. --- libglabels/xml-template.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; } -- 2.39.5