summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2017-08-30 09:32:21 -0500
committerBen Loftis <ben@harrisonconsoles.com>2017-08-30 10:23:34 -0500
commit7d880912291992392131b2928482d77d3505f126 (patch)
treed2293f357f698257610f0f961d6ad806a0f33a6c /libs/pbd
parent86222360a3ba54bbc4f5817c1efc2d3aea8aaf36 (diff)
Avoid assert() when loading xml: Throw an XMLerror if attribute_value fails.
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pbd/xml++.h2
-rw-r--r--libs/pbd/xml++.cc12
2 files changed, 10 insertions, 4 deletions
diff --git a/libs/pbd/pbd/xml++.h b/libs/pbd/pbd/xml++.h
index 4b012c910e..2ca9375ec3 100644
--- a/libs/pbd/pbd/xml++.h
+++ b/libs/pbd/pbd/xml++.h
@@ -131,7 +131,7 @@ public:
XMLNode* add_child_copy(const XMLNode&);
void add_child_nocopy(XMLNode&);
- std::string attribute_value();
+ std::string attribute_value(); //throws XMLException if attribute doesn't exist
const XMLPropertyList& properties() const { return _proplist; }
XMLProperty const * property(const char*) const;
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();
}