From 39f765614a7964e07c55a57ba854f8524807d6cb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 17 Dec 2011 16:37:18 +0000 Subject: [PATCH] Clear up confusion with overloads of _frozen and frozen() meaning different things. git-svn-id: svn://localhost/ardour2/branches/3.0@11016 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/region.cc | 2 +- libs/pbd/pbd/stateful.h | 7 +++---- libs/pbd/stateful.cc | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index dde4e51530..adc6334334 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1301,7 +1301,7 @@ Region::send_change (const PropertyChange& what_changed) Stateful::send_change (what_changed); - if (!Stateful::frozen()) { + if (!Stateful::property_changes_suspended()) { /* Try and send a shared_pointer unless this is part of the constructor. If so, do nothing. diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h index 2d5b2a0990..506d058773 100644 --- a/libs/pbd/pbd/stateful.h +++ b/libs/pbd/pbd/stateful.h @@ -90,9 +90,9 @@ class Stateful { virtual void suspend_property_changes (); virtual void resume_property_changes (); - - virtual bool frozen() const { return _frozen; } + bool property_changes_suspended() const { return g_atomic_int_get (&_stateful_frozen) > 0; } + protected: void add_instant_xml (XMLNode&, const sys::path& directory_path); @@ -109,7 +109,6 @@ class Stateful { XMLNode *_extra_xml; XMLNode *_instant_xml; - int32_t _frozen; PBD::PropertyChange _pending_changed; Glib::Mutex _lock; @@ -121,10 +120,10 @@ class Stateful { within thaw() just before send_change() is called. */ virtual void mid_thaw (const PropertyChange&) { } - bool property_changes_suspended() const { return g_atomic_int_get (&_frozen) > 0; } private: PBD::ID _id; + int32_t _stateful_frozen; }; } // namespace PBD diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc index b2c76f452f..0cea6324f5 100644 --- a/libs/pbd/stateful.cc +++ b/libs/pbd/stateful.cc @@ -39,8 +39,8 @@ int Stateful::current_state_version = 0; int Stateful::loading_state_version = 0; Stateful::Stateful () - : _frozen (0) - , _properties (new OwnedPropertyList) + : _properties (new OwnedPropertyList) + , _stateful_frozen (0) { _extra_xml = 0; _instant_xml = 0; @@ -275,7 +275,7 @@ Stateful::send_change (const PropertyChange& what_changed) { Glib::Mutex::Lock lm (_lock); - if (_frozen) { + if (property_changes_suspended ()) { _pending_changed.add (what_changed); return; } @@ -287,7 +287,7 @@ Stateful::send_change (const PropertyChange& what_changed) void Stateful::suspend_property_changes () { - _frozen++; + g_atomic_int_add (&_stateful_frozen, 1); } void @@ -298,7 +298,7 @@ Stateful::resume_property_changes () { Glib::Mutex::Lock lm (_lock); - if (_frozen && --_frozen > 0) { + if (property_changes_suspended() && g_atomic_int_dec_and_test (&_stateful_frozen) == FALSE) { return; }