Don't add standard processors twice to routes from 2.X sessions. Fixes #3434.
[ardour.git] / libs / pbd / xml++.cc
index ec1c8a7b60f51cef8878be0b6cf379927d9f8555..dbed9d191750d6ee812008f31a0e71476b417a4b 100644 (file)
@@ -5,6 +5,7 @@
  * Modified for Ardour and released under the same terms.
  */
 
+#include <iostream>
 #include "pbd/xml++.h"
 #include <libxml/debugXML.h>
 #include <libxml/xpath.h>
@@ -68,7 +69,7 @@ XMLTree::read_internal(bool validate)
        delete _root;
        _root = 0;
 
-       xmlParserCtxtPtr ctxt; /* the parser context */
+       xmlParserCtxtPtr ctxt = NULL; /* the parser context */
        xmlDocPtr doc; /* the resulting document tree */
 
        xmlKeepBlanksDefault(0);
@@ -95,7 +96,6 @@ XMLTree::read_internal(bool validate)
                if (validate && ctxt->valid == 0) {
                        xmlFreeParserCtxt(ctxt);
                        xmlFreeDoc(doc);
-                       xmlCleanupParser();
                        throw XMLException("Failed to validate document " + _filename);
                }
        }
@@ -107,7 +107,6 @@ XMLTree::read_internal(bool validate)
                xmlFreeParserCtxt(ctxt);
        }
        xmlFreeDoc(doc);
-       xmlCleanupParser();
 
        return true;
 }
@@ -413,7 +412,9 @@ void
 XMLNode::remove_property(const string& n)
 {
        if (_propmap.find(n) != _propmap.end()) {
-               _proplist.remove(_propmap[n]);
+               XMLProperty* p = _propmap[n];
+               _proplist.remove (p);
+               delete p;
                _propmap.erase(n);
        }
 }
@@ -589,3 +590,17 @@ static XMLSharedNodeList* find_impl(xmlXPathContext* ctxt, const string& xpath)
        return nodes;
 }
 
+/** Dump a node, its properties and children to a stream */
+void
+XMLNode::dump (ostream& s, string p) const
+{
+       s << p << _name << " ";
+       for (XMLPropertyList::const_iterator i = _proplist.begin(); i != _proplist.end(); ++i) {
+               s << (*i)->name() << "=" << (*i)->value() << " ";
+       }
+       s << "\n";
+       
+       for (XMLNodeList::const_iterator i = _children.begin(); i != _children.end(); ++i) {
+               (*i)->dump (s, p + "  ");
+       }
+}