save+restore ID counter; fix buglet introduced with ID's when saving region state
git-svn-id: svn://localhost/ardour2/trunk@672 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -655,7 +655,7 @@ AudioRegion::state (bool full)
|
||||
|
||||
for (uint32_t n=0; n < sources.size(); ++n) {
|
||||
snprintf (buf2, sizeof(buf2), "source-%d", n);
|
||||
sources[n]->id().print (buf2);
|
||||
sources[n]->id().print (buf);
|
||||
node.add_property (buf2, buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,8 @@ ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization)
|
||||
|
||||
(void) bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
|
||||
ID::init ();
|
||||
|
||||
Config = new Configuration;
|
||||
|
||||
if (Config->load_state ()) {
|
||||
|
||||
@@ -1333,6 +1333,13 @@ Session::state(bool full_state)
|
||||
}
|
||||
}
|
||||
|
||||
/* save the ID counter */
|
||||
|
||||
snprintf (buf, sizeof (buf), "%" PRIu64, ID::counter());
|
||||
node->add_property ("id-counter", buf);
|
||||
|
||||
/* various options */
|
||||
|
||||
node->add_child_nocopy (get_options());
|
||||
|
||||
child = node->add_child ("Sources");
|
||||
@@ -1502,6 +1509,21 @@ Session::set_state (const XMLNode& node)
|
||||
if ((prop = node.property ("name")) != 0) {
|
||||
_name = prop->value ();
|
||||
}
|
||||
|
||||
if ((prop = node.property (X_("id-counter"))) != 0) {
|
||||
uint64_t x;
|
||||
sscanf (prop->value().c_str(), "%" PRIu64, &x);
|
||||
ID::init_counter (x);
|
||||
} else {
|
||||
/* old sessions used a timebased counter, so fake
|
||||
the startup ID counter based on a standard
|
||||
timestamp.
|
||||
*/
|
||||
time_t now;
|
||||
time (&now);
|
||||
ID::init_counter (now);
|
||||
}
|
||||
|
||||
|
||||
IO::disable_ports ();
|
||||
IO::disable_connecting ();
|
||||
|
||||
@@ -12,12 +12,18 @@
|
||||
using namespace std;
|
||||
using namespace PBD;
|
||||
|
||||
Glib::Mutex ID::counter_lock;
|
||||
Glib::Mutex* ID::counter_lock = 0;
|
||||
uint64_t ID::_counter = 0;
|
||||
|
||||
void
|
||||
ID::init ()
|
||||
{
|
||||
counter_lock = new Glib::Mutex;
|
||||
}
|
||||
|
||||
ID::ID ()
|
||||
{
|
||||
Glib::Mutex::Lock lm (counter_lock);
|
||||
Glib::Mutex::Lock lm (*counter_lock);
|
||||
id = _counter++;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,13 @@ class ID {
|
||||
|
||||
static uint64_t counter() { return _counter; }
|
||||
static void init_counter (uint64_t val) { _counter = val; }
|
||||
static void init ();
|
||||
|
||||
private:
|
||||
uint64_t id;
|
||||
int string_assign (std::string);
|
||||
|
||||
static Glib::Mutex counter_lock;
|
||||
static Glib::Mutex* counter_lock;
|
||||
static uint64_t _counter;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user