diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2017-08-30 10:20:29 -0500 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2017-08-30 10:23:34 -0500 |
commit | 1f6c54a2f053caa8afec70f2acffdb7f7d73f09f (patch) | |
tree | 8f4f3df4ffb4a9d0f8c3206154e4cb6290504287 /libs/ardour/template_utils.cc | |
parent | 7d880912291992392131b2928482d77d3505f126 (diff) |
Gracefully handle templates that lack contents in their description or created_with node.
Diffstat (limited to 'libs/ardour/template_utils.cc')
-rw-r--r-- | libs/ardour/template_utils.cc | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index 80baf47f54..5c6fd9c833 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -101,26 +101,32 @@ find_session_templates (vector<TemplateInfo>& template_names, bool read_xml) rti.path = *i; if (read_xml) { + XMLTree tree; if (!tree.read (file.c_str())) { + cerr << "Failed to parse Route-template XML file: " << file; continue; } - string created_with = _("(unknown)"); - XMLNode *pv = tree.root()->child("ProgramVersion"); - if (pv != 0) { - pv->get_property (X_("created-with"), created_with); - } - - string description = _("No Description"); - XMLNode *desc = tree.root()->child("description"); - if (desc != 0) { - description = desc->attribute_value(); - } - - rti.created_with = created_with; - rti.description = description; - + XMLNode* root = tree.root(); + + rti.created_with = _("(unknown)"); + try { + XMLNode *pv = root->child("ProgramVersion"); + string created_with; + if (pv != 0) { + pv->get_property (X_("created-with"), created_with); + } + rti.created_with = created_with; + } catch ( LIBPBD_API::XMLException &e) {} + + rti.description = _("No Description"); + try { + XMLNode *desc = root->child("description"); + if (desc != 0) { + rti.description = desc->attribute_value(); + } + } catch ( LIBPBD_API::XMLException &e) {} } template_names.push_back (rti); @@ -144,22 +150,34 @@ find_route_templates (vector<TemplateInfo>& template_names) XMLTree tree; if (!tree.read (fullpath.c_str())) { + cerr << "Failed to parse Route-template XML file: " << fullpath; continue; } XMLNode* root = tree.root(); - string description = _("No Description"); - XMLNode* desc = tree.root()->child ("description"); - if (desc) { - description = desc->attribute_value (); - } - TemplateInfo rti; + rti.created_with = _("(unknown)"); + try { + XMLNode *pv = root->child("ProgramVersion"); + string created_with; + if (pv != 0) { + pv->get_property (X_("created-with"), created_with); + } + rti.created_with = created_with; + } catch ( LIBPBD_API::XMLException &e) {} + + rti.description = _("No Description"); + try { + XMLNode *desc = root->child("description"); + if (desc != 0) { + rti.description = desc->attribute_value(); + } + } catch ( LIBPBD_API::XMLException &e) {} + rti.name = IO::name_from_state (*root->children().front()); rti.path = fullpath; - rti.description = description; template_names.push_back (rti); } |