Fixed double delete in Stateful::add_instant_xml().

git-svn-id: svn://localhost/ardour2/trunk@690 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Taybin Rutkin 2006-07-22 16:21:10 +00:00
parent 433d9a5fc3
commit 3a5a338f80
7 changed files with 27 additions and 45 deletions

View 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 */

View 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)
{

View 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());
}

View 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,17 +80,16 @@ 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&);
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; };

View 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;
}

View 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;