better design for range plays that leaves the range play button able to play the...
[ardour.git] / libs / pbd / xml++.cc
index 1b10be89f5df6102366bb05cdd7b6c88a9551730..cf78ca53973cb12d4e64fb31e93892be0782e9a1 100644 (file)
@@ -110,7 +110,7 @@ XMLTree::write(void) const
        doc = xmlNewDoc((xmlChar *) "1.0");
        xmlSetDocCompressMode(doc, _compression);
        writenode(doc, _root, doc->children, 1);
-       result = xmlSaveFormatFile(_filename.c_str(), doc, 1);
+       result = xmlSaveFormatFileEnc(_filename.c_str(), doc, "UTF-8", 1);
        xmlFreeDoc(doc);
        
        if (result == -1) {
@@ -221,15 +221,12 @@ XMLNode::child (const char *name) const
 {
        /* returns first child matching name */
 
-       static XMLNodeList retval;
        XMLNodeConstIterator cur;
        
        if (name == 0) {
                return 0;
        }
            
-       retval.erase(retval.begin(), retval.end());
-       
        for (cur = _children.begin(); cur != _children.end(); ++cur) {
                if ((*cur)->name() == name) {
                        return *cur;
@@ -244,22 +241,21 @@ XMLNode::children(const string& n) const
 {
        /* returns all children matching name */
 
-       static XMLNodeList retval;
        XMLNodeConstIterator cur;
        
        if (n.empty()) {
                return _children;
        }
-           
-       retval.erase(retval.begin(), retval.end());
+
+       _selected_children.clear();
        
        for (cur = _children.begin(); cur != _children.end(); ++cur) {
                if ((*cur)->name() == n) {
-                       retval.insert(retval.end(), *cur);
+                       _selected_children.insert(_selected_children.end(), *cur);
                }
        }
            
-       return retval;
+       return _selected_children;
 }
 
 XMLNode *
@@ -292,11 +288,25 @@ XMLProperty *
 XMLNode::property(const char * n)
 {
        string ns(n);
-       if (_propmap.find(ns) == _propmap.end()) {
-               return 0;
+       map<string,XMLProperty*>::iterator iter;
+
+       if ((iter = _propmap.find(ns)) != _propmap.end()) {
+               return iter->second;
+       }
+
+       return 0;
+}
+
+XMLProperty *
+XMLNode::property(const string & ns)
+{
+       map<string,XMLProperty*>::iterator iter;
+
+       if ((iter = _propmap.find(ns)) != _propmap.end()) {
+               return iter->second;
        }
        
-       return _propmap[ns];
+       return 0;
 }
 
 XMLProperty *
@@ -330,7 +340,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);
        }
 }