diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2017-08-30 09:32:21 -0500 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2017-08-30 10:23:34 -0500 |
commit | 7d880912291992392131b2928482d77d3505f126 (patch) | |
tree | d2293f357f698257610f0f961d6ad806a0f33a6c /libs/pbd/xml++.cc | |
parent | 86222360a3ba54bbc4f5817c1efc2d3aea8aaf36 (diff) |
Avoid assert() when loading xml: Throw an XMLerror if attribute_value fails.
Diffstat (limited to 'libs/pbd/xml++.cc')
-rw-r--r-- | libs/pbd/xml++.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index 23ecfabc91..c18d36f065 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -466,10 +466,16 @@ std::string XMLNode::attribute_value() { XMLNodeList children = this->children(); - assert(!_is_content); - assert(children.size() == 1); + if (_is_content) + throw XMLException("XMLNode: attribute_value failed (is_content) for requested node: " + name()); + + if (children.size() != 1) + throw XMLException("XMLNode: attribute_value failed (children.size != 1) for requested node: " + name()); + XMLNode* child = *(children.begin()); - assert(child->is_content()); + if (!child->is_content()) + throw XMLException("XMLNode: attribute_value failed (!child->is_content()) for requested node: " + name()); + return child->content(); } |