13
0
livetrax/libs/pbd
Paul Davis bc7f25e52c libpbd: AbstractUI must call & destroy sigc::trackable callbacks in its destructor
AbstractUI IS-A BaseUI IS-A EventLoop
                       IS-A sigc::trackable

If we have sent a call_slot() request to an EventLoop that has not executed
when the object involved in the call_slot() functor is destroyed, we need to
ensure that the request is invalidated.

To do this, We register "notify" callbacks with the sigc::trackable that is a
base class of the object involved in the functor given to
call_slot(). sigc::trackable will call these "notify" callbacks from its
destructor.

So when the call_slot() functor's relevant object dies, and its sigc::trackable
base class is destroyed, it will invoke all of its the "notify" callbacks, which will
in turn call EventLoop::invalidate_request() and this hopefully marks all the
queued call_slot() functors as "do not call".

However, invalidate_request() requires a lock, and access to the lock is
granted via a pure virtual, EventLoop::slot_invalidation_lock(). In the
heirarchy cited above, this is implemented by AbstractUI.

When we destroy an AbstractUI, ~AbstractUI() is called first, and this destroys
the lock and changes the VTT so that ::slot_invalidation_lock() becomes a pure
virtual again.

Eventually we will call ~trackable() which in turns runs all the "notify"
callbacks, and then removes them. But when these callbacks end up in
EventLoop::invalidate_request(), we try to call ::slot_invalidation_lock() and
C++ will abort because of its (now) pure virtual status.

Therefore, we must invoke the "notify" callbacks before the
::slot_invalidation_lock() becomes pure, and that means inside ~AbstractUI, as
an explicit call to trackable::notify_callbacks().

This has not appeared before (remarkably), but became an issue when the
Launchpad Pro support code's main object (derived from MIDISurface and hence
from AbstractUI) "failed" to use sub-objects for its various methods. So when
it connects to, for example, the Session::RouteAddedOrRemoved signal, it is
connecting itself (derived from a sigc::trackable). When the Launchpad Pro
object is destroyed, it tries to invalidate all the call_slot() requests, but
this requires access to an event loop lock - owned by the Launchpad Pro event
loop, which is already destroyed!

Other surfaces have generally avoided this by using other objects to provide
methods of dealing with signals from libardour objects.
2023-08-30 16:06:14 -06:00
..
boost-debug
msvc
MSVCpbd
pbd libpbd: AbstractUI must call & destroy sigc::trackable callbacks in its destructor 2023-08-30 16:06:14 -06:00
test Make RCU reader return a const pointer (omnibus commit) 2023-04-08 00:15:37 +02:00
base_ui.cc
basename.cc
boost_debug.cc
cartesian.cc
ChangeLog
cocoa_open_uri.mm Use macOS API to open finder at given path 2022-12-08 02:15:29 +01:00
command.cc pbd: fairly unconscionable that Command in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
configuration_variable.cc continued work on use of Metadata in various Configuration objects (libs edition) 2023-01-27 15:13:27 -07:00
controllable.cc switch from boost::{shared,weak}_ptr to std::{shared,weak}_ptr 2023-03-24 14:19:15 -06:00
convert.cc add upcase() method; remove upcase version of internationalize() 2023-01-27 15:13:27 -07:00
COPYING
cpus.cc
crossthread.cc
crossthread.posix.cc
crossthread.win.cc
debug_rt_alloc.c
debug.cc use PBD::DEBUG::Threads as a toggle to show thread ID/name with debug output 2023-08-30 16:06:13 -06:00
demangle.cc
downloader.cc
enums.cc
enumwriter.cc
epa.cc
error.cc
event_loop.cc libpbd/guis: move __invalidator() into PBD::EventLoop 2023-08-30 16:06:14 -06:00
ffs.cc
file_archive.cc Implement FileArchive progress/cancel 2023-05-19 03:08:22 +02:00
file_utils.cc Catch Glib::ConvertError when checking for files 2023-04-03 22:10:11 +02:00
fpu.cc Fix non-intel arch builds (cpuid.h header) 2023-02-09 20:54:46 +01:00
glib_event_source.cc
id.cc
inflater.cc Implement FileArchive progress/cancel 2023-05-19 03:08:22 +02:00
libpbd.pc.in
libpbd.spec.in
locale_guard.cc
localtime_r.cc
malign.cc
md5.cc
microseconds.cc
mountpoint.cc
openuri.cc Use macOS API to open finder at given path 2022-12-08 02:15:29 +01:00
pathexpand.cc
pbd.cc
pcg_rand.cc
pool.cc switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06:00
progress.cc Move Ardour::Progress to PBD::Progress 2023-05-19 00:35:20 +02:00
property_list.cc libpbd: add operator<< for PropertyChange 2023-08-30 16:06:13 -06:00
pthread_utils.cc pthread_setname_np is available with GNU/mingw 2023-06-17 23:49:47 +02:00
reallocpool.cc Fix unused computed values 2022-12-11 11:54:03 -05:00
receiver.cc
resource.cc
run-tests.sh
search_path.cc
semutils.cc Explicitly initialize futex word 2022-11-13 03:01:50 +01:00
shortpath.cc
signals.cc
spinlock.cc
stacktrace.cc
stateful_diff_command.cc switch from boost::{shared,weak}_ptr to std::{shared,weak}_ptr 2023-03-24 14:19:15 -06:00
stateful.cc switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06:00
string_convert.cc
strreplace.cc
strsplit.cc
system_exec.cc Tweak Window system-exec, wait for process to terminate 2023-04-05 00:16:37 +02:00
textreceiver.cc
timer.cc
timing.cc
tlsf.cc
transmitter.cc
undo.cc pbd: fairly unconscionable that Command in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
utf8_utils.cc Add API to sanitize UTF-8 strings 2023-04-26 17:25:24 +02:00
uuid.cc
whitespace.cc
windows_mmcss.cc
windows_special_dirs.cc
windows_timer_utils.cc
wscript Move Ardour::Progress to PBD::Progress 2023-05-19 00:35:20 +02:00
xml++.cc Sanitize XML values to be valid UTF-8 (#9317) 2023-04-26 17:43:52 +02:00