summaryrefslogtreecommitdiff
path: root/libs/pbd/stateful.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-11-12 10:24:41 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-11-12 10:24:41 -0500
commit92fe47bdeec3864d69c10b538851d1f7f0cceaaf (patch)
treeae475552c51efdee281281e15b37d212ee613626 /libs/pbd/stateful.cc
parent487a2563a692f321538238e67d094cee86175239 (diff)
provide a mechanism to force ID regeneration/reset in PBD::Stateful when settingthe ID object from XML or string sources
Diffstat (limited to 'libs/pbd/stateful.cc')
-rw-r--r--libs/pbd/stateful.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
index 2cc40ff6a9..628594891b 100644
--- a/libs/pbd/stateful.cc
+++ b/libs/pbd/stateful.cc
@@ -44,6 +44,10 @@ namespace PBD {
int Stateful::current_state_version = 0;
int Stateful::loading_state_version = 0;
+static void do_not_delete (void*) { }
+
+Glib::Threads::Private<bool> Stateful::regenerate_xml_or_string_ids (do_not_delete);
+
Stateful::Stateful ()
: _extra_xml (0)
, _instant_xml (0)
@@ -382,6 +386,11 @@ Stateful::set_id (const XMLNode& node)
{
const XMLProperty* prop;
+ if (regenerate_xml_or_string_ids.get()) {
+ reset_id ();
+ return true;
+ }
+
if ((prop = node.property ("id")) != 0) {
_id = prop->value ();
return true;
@@ -399,7 +408,17 @@ Stateful::reset_id ()
void
Stateful::set_id (const string& str)
{
- _id = str;
+ if (regenerate_xml_or_string_ids.get()) {
+ reset_id ();
+ } else {
+ _id = str;
+ }
+}
+
+void
+Stateful::set_regenerate_xml_and_string_ids_in_this_thread (bool yn)
+{
+ regenerate_xml_or_string_ids.set (&yn);
}
} // namespace PBD