diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2017-01-28 11:10:18 +0100 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2017-01-28 11:10:18 +0100 |
commit | 5e76d8537b891de577815a57f36da45752a2dac4 (patch) | |
tree | fa7c5cc89f01847dfbdd6e8055f8f41cf4d92759 | |
parent | e998ef5a75c6bdd6a2146acbbe7318069d607117 (diff) |
improved (as in "correct") deadlock fix for PresentationInfo::Change
-rw-r--r-- | libs/ardour/presentation_info.cc | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/libs/ardour/presentation_info.cc b/libs/ardour/presentation_info.cc index 64d2a35828..87a091ebbe 100644 --- a/libs/ardour/presentation_info.cc +++ b/libs/ardour/presentation_info.cc @@ -61,37 +61,31 @@ PresentationInfo::suspend_change_signal () void PresentationInfo::unsuspend_change_signal () { + Glib::Threads::Mutex::Lock lm (static_signal_lock); + if (g_atomic_int_get (const_cast<gint*> (&_change_signal_suspended)) == 1) { /* atomically grab currently pending flags */ - PropertyChange pc; - - { - Glib::Threads::Mutex::Lock lm (static_signal_lock); - pc = _pending_static_changes; - _pending_static_changes.clear (); - } + PropertyChange pc = _pending_static_changes; + _pending_static_changes.clear (); if (!pc.empty()) { - std::cerr << "PI change (unsuspended): "; - for (PropertyChange::const_iterator x = pc.begin(); x != pc.end(); ++x) { - std::cerr << g_quark_to_string (*x) << ','; - } - std::cerr << '\n'; - - /* emit the signal with further emissions still - * blocked, so that if the handlers modify other PI - * states, the signal for that won't be sent while - * they are handling this one. + /* emit the signal with further emissions still blocked + * by _change_signal_suspended, but not by the lock. + * + * This means that if the handlers modify other PI + * states, the signal for that won't be sent while they + * are handling the current signal. */ - + lm.release (); Change (pc); /* EMIT SIGNAL */ + lm.acquire (); } - - g_atomic_int_add (const_cast<gint*>(&_change_signal_suspended), -1); } + + g_atomic_int_add (const_cast<gint*>(&_change_signal_suspended), -1); } void |