Fixed double delete in Stateful::add_instant_xml().
authorTaybin Rutkin <taybin@taybin.com>
Sat, 22 Jul 2006 16:21:10 +0000 (16:21 +0000)
committerTaybin Rutkin <taybin@taybin.com>
Sat, 22 Jul 2006 16:21:10 +0000 (16:21 +0000)
git-svn-id: svn://localhost/ardour2/trunk@690 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/editor.cc
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/pbd/pbd/xml++.h
libs/pbd/stateful.cc
libs/pbd/xml++.cc

index 1887f046b8ad26ea3c7de2d6f756bcc606737c80..732c829a3858a59c97247bb473f22b83b7d61b09 100644 (file)
@@ -339,15 +339,15 @@ ARDOUR_UI::save_ardour_state ()
        Config->add_extra_xml (*node);
        Config->save_state();
 
-       XMLNode* enode = new XMLNode (static_cast<Stateful*>(editor)->get_state());
-       XMLNode* mnode = new XMLNode (mixer->get_state());
+       XMLNode enode(static_cast<Stateful*>(editor)->get_state());
+       XMLNode mnode(mixer->get_state());
 
        if (session) {
-               session->add_instant_xml(*enode, session->path());
-               session->add_instant_xml(*mnode, session->path());
+               session->add_instant_xml (enode, session->path());
+               session->add_instant_xml (mnode, session->path());
        } else {
-               Config->add_instant_xml(*enode, get_user_ardour_path());
-               Config->add_instant_xml(*mnode, get_user_ardour_path());
+               Config->add_instant_xml (enode, get_user_ardour_path());
+               Config->add_instant_xml (mnode, get_user_ardour_path());
        }
 
        /* keybindings */
index 2512c082db78a43c9596b252f386e7594dd7bc36..24b367e921281a08341540acd7907142ea04a76a 100644 (file)
@@ -913,7 +913,7 @@ Editor::set_frames_per_unit (double fpu)
 void
 Editor::instant_save ()
 {
-        if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
+       if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
                return;
        }
 
@@ -2295,7 +2295,7 @@ Editor::get_state ()
        char buf[32];
 
        if (is_realized()) {
-               Glib::RefPtr<Gdk::Window> win = get_window();
+               Glib::RefPtr<Gdk::Window> win = get_window();
                
                int x, y, xoff, yoff, width, height;
                win->get_root_origin(x, y);
index 3f400b0b2b3edad3a9f49ffd12e8ab4d877fe754..34807e798b25c2c0582f4f68dc93e1862fb1bd08 100644 (file)
@@ -3558,13 +3558,6 @@ Session::allocate_pan_automation_buffers (jack_nframes_t nframes, uint32_t howma
        _npan_buffers = howmany;
 }
 
-void 
-Session::add_instant_xml (XMLNode& node, const std::string& dir)
-{
-       Stateful::add_instant_xml (node, dir);
-       Config->add_instant_xml (node, get_user_ardour_path());
-}
-
 int
 Session::freeze (InterThreadInfo& itt)
 {
index 35d56760a960e0554e20e56c8198278003b1da84..6fb60ebcab858eaabe54f87e1527424187bcf22a 100644 (file)
@@ -3284,3 +3284,10 @@ Session::controllable_by_id (const PBD::ID& id)
 
        return 0;
 }
+
+void 
+Session::add_instant_xml (XMLNode& node, const std::string& dir)
+{
+       Stateful::add_instant_xml (node, dir);
+       Config->add_instant_xml (node, get_user_ardour_path());
+}
index afb896e1d537c57fdec265c21c703fa2c8e5684f..5dcb4f084aa5e9ea9a1a575c2006b8b6f10cce89 100644 (file)
@@ -37,7 +37,6 @@ private:
   string _filename;
   XMLNode *_root;
   int _compression;
-  bool _initialized;
 
 public:
   XMLTree();
@@ -45,9 +44,8 @@ public:
   XMLTree(const XMLTree *);
   ~XMLTree();
 
-  bool initialized() const { return _initialized; };
   XMLNode *root() const { return _root; };
-  XMLNode *set_root(XMLNode *n) { _initialized = true; return _root = n; };
+  XMLNode *set_root(XMLNode *n) { return _root = n; };
 
   const string & filename() const { return _filename; };
   const string & set_filename(const string &fn) { return _filename = fn; };
@@ -69,7 +67,6 @@ public:
 
 class XMLNode {
 private:
-  bool _initialized;
   string _name;
   bool _is_content;
   string _content;
@@ -83,18 +80,17 @@ public:
   XMLNode(const XMLNode&);
   ~XMLNode();
 
-  bool initialized() const { return _initialized; };
   const string name() const { return _name; };
 
   bool is_content() const { return _is_content; };
   const string & content() const { return _content; };
-  const string & set_content(const string &);
+  const string & set_content (const string &);
   XMLNode *add_content(const string & = string());
 
-  const XMLNodeList & children(const string & = string()) const;
-  XMLNode *add_child(const char *);
-  XMLNode *add_child_copy(const XMLNode&);
-  void     add_child_nocopy (XMLNode&);
+  const XMLNodeList & children (const string & = string()) const;
+  XMLNode *add_child (const char *);
+  XMLNode *add_child_copy (const XMLNode&);
+  void add_child_nocopy (XMLNode&);
 
   const XMLPropertyList & properties() const { return _proplist; };
   XMLProperty *property(const char * );
index f0f820fe9ddb1a668c9ea1c0eedfbc250d16a5ba..786410e817f965ad96b7c6b0abe3e5436a188c83 100644 (file)
@@ -82,7 +82,7 @@ Stateful::add_instant_xml (XMLNode& node, const string& dir)
        }
 
        _instant_xml->remove_nodes_and_delete (node.name());
-       _instant_xml->add_child_nocopy (node);
+       _instant_xml->add_child_copy (node);
        
        XMLTree tree;
        tree.set_filename(dir+"/instant.xml");
@@ -134,4 +134,3 @@ Stateful::instant_xml (const string& str, const string& dir)
 
        return 0;
 }
-
index dec5c346cc94b9e8bb45f31b3164b5482ad59311..03fa11627976ca6bff3fa26ad1fcec849acaf8b6 100644 (file)
@@ -12,17 +12,15 @@ static void writenode(xmlDocPtr, XMLNode *, xmlNodePtr, int);
 
 XMLTree::XMLTree() 
        : _filename(), 
-       _root(), 
-       _compression(0), 
-       _initialized(false) 
+       _root(0), 
+       _compression(0)
 { 
 }
 
 XMLTree::XMLTree(const string &fn)
        : _filename(fn), 
        _root(0), 
-       _compression(0), 
-       _initialized(false) 
+       _compression(0)
 { 
        read(); 
 }
@@ -32,13 +30,13 @@ XMLTree::XMLTree(const XMLTree * from)
        _filename = from->filename();
        _root = new XMLNode(*from->root());
        _compression = from->compression();
-       _initialized = true;
 }
 
 XMLTree::~XMLTree()
 {
-       if (_initialized && _root)
+       if (_root) {
                delete _root;
+       }
 }
 
 int 
@@ -69,13 +67,11 @@ XMLTree::read(void)
        
        doc = xmlParseFile(_filename.c_str());
        if (!doc) {
-               _initialized = false;
                return false;
        }
        
        _root = readnode(xmlDocGetRootElement(doc));
        xmlFreeDoc(doc);
-       _initialized = true;
        
        return true;
 }
@@ -94,13 +90,11 @@ XMLTree::read_buffer(const string & buffer)
        
        doc = xmlParseMemory((char *) buffer.c_str(), buffer.length());
        if (!doc) {
-               _initialized = false;
                return false;
        }
        
        _root = readnode(xmlDocGetRootElement(doc));
        xmlFreeDoc(doc);
-       _initialized = true;
        
        return true;
 }
@@ -166,21 +160,14 @@ XMLTree::write_buffer(void) const
 XMLNode::XMLNode(const string & n)
        :  _name(n), _is_content(false), _content(string())
 {
-       if (_name.empty()) {
-               _initialized = false;
-       } else {
-               _initialized = true;
-       }
 }
 
 XMLNode::XMLNode(const string & n, const string & c)
        :_name(n), _is_content(true), _content(c)
 {
-       _initialized = true;
 }
 
 XMLNode::XMLNode(const XMLNode& from)
-       : _initialized(false)
 {
        XMLPropertyList props;
        XMLPropertyIterator curprop;