summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/stateful.h
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/pbd/stateful.h
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/pbd/stateful.h')
-rw-r--r--libs/pbd/pbd/stateful.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
index 8a86e47285..0207cfcf0c 100644
--- a/libs/pbd/pbd/stateful.h
+++ b/libs/pbd/pbd/stateful.h
@@ -70,6 +70,17 @@ class LIBPBD_API Stateful {
void set_id (const std::string&);
void reset_id ();
+ /* RAII structure to manage thread-local ID regeneration.
+ */
+ struct ForceIDRegeneration {
+ ForceIDRegeneration () {
+ set_regenerate_xml_and_string_ids_in_this_thread (true);
+ }
+ ~ForceIDRegeneration () {
+ set_regenerate_xml_and_string_ids_in_this_thread (false);
+ }
+ };
+
/* history management */
void clear_changes ();
@@ -121,11 +132,14 @@ class LIBPBD_API Stateful {
virtual void mid_thaw (const PropertyChange&) { }
private:
+ friend struct ForceIDRegeneration;
+ static Glib::Threads::Private<bool> regenerate_xml_or_string_ids;
PBD::ID _id;
gint _stateful_frozen;
+
+ static void set_regenerate_xml_and_string_ids_in_this_thread (bool yn);
};
} // namespace PBD
#endif /* __pbd_stateful_h__ */
-