ardour/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 Emulate exp2f() for older MS compilers where it wasn't available 2021-05-05 17:50:41 +01:00
MSVCpbd Add an extra dependency lib which was previously only needed for Debug builds 2021-07-15 09:30:08 +01:00
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 libpbd: do not use debug transmitter inside BaseUI::signal_new_request() to avoid recursion 2022-06-13 13:43:31 -06:00
basename.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
boost_debug.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
cartesian.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
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 Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
crossthread.cc Potential fix for M1 x-thread events 2022-05-02 00:02:33 +02:00
crossthread.posix.cc NO-OP: clang-format 2022-04-23 23:12:13 +02:00
crossthread.win.cc Some initial changes (currently for libpbd only) to help a new contributer who's trying to build with MSVC2017 2020-03-26 10:40:36 +00:00
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
debug_rt_alloc.c Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
demangle.cc Fix crash when demangled symbol is n/a 2021-07-19 18:26:22 +02:00
downloader.cc downloader: create destdir if it does not already exist, throw exception if this fails 2022-09-26 01:10:20 -06:00
enums.cc Add flag to explicitly hide a control 2020-03-18 18:16:29 +01:00
enumwriter.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
epa.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
error.cc Add debug transmitter 2020-10-13 21:27:16 +02:00
event_loop.cc libpbd/guis: move __invalidator() into PBD::EventLoop 2023-08-30 16:06:14 -06:00
ffs.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
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 libpbd: change GlibEventLoopCallback to use C API not C++ 2022-05-19 22:24:43 -06:00
id.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
inflater.cc Implement FileArchive progress/cancel 2023-05-19 03:08:22 +02:00
libpbd.pc.in
libpbd.spec.in
locale_guard.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
localtime_r.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
malign.cc Fix alignment unit-tests and ARM/NEON alignment 2020-10-15 03:55:42 +02:00
md5.cc
microseconds.cc NOOP: remove incomplete comment 2021-06-27 12:48:29 -06:00
mountpoint.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
openuri.cc Use macOS API to open finder at given path 2022-12-08 02:15:29 +01:00
pathexpand.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
pbd.cc window compilation fix 2021-06-26 18:47:08 -06:00
pcg_rand.cc Amend 55211b8d (PRNG seed, use local address) 2021-08-16 04:59:10 +02:00
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 Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
resource.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
run-tests.sh
search_path.cc Prevent duplicate search paths 2020-12-02 21:34:52 +01:00
semutils.cc Explicitly initialize futex word 2022-11-13 03:01:50 +01:00
shortpath.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
signals.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
spinlock.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
stacktrace.cc miscellaneous fixes for warnings from -Wconversion 2022-07-04 22:01:48 -06:00
stateful.cc switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06:00
stateful_diff_command.cc switch from boost::{shared,weak}_ptr to std::{shared,weak}_ptr 2023-03-24 14:19:15 -06:00
string_convert.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
strreplace.cc Fix poor_mans_glob, ~' for $HOME' is only valid at the start of a path 2022-02-01 15:47:54 +01:00
strsplit.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
system_exec.cc Tweak Window system-exec, wait for process to terminate 2023-04-05 00:16:37 +02:00
textreceiver.cc Add debug transmitter 2020-10-13 21:27:16 +02:00
timer.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
timing.cc change PBD::microseconds_t to a signed type and check for -1 in TimingStats::update 2021-06-28 14:47:48 -06:00
tlsf.cc use C style cast in C code, rather than C++ constructor 2022-06-22 13:31:08 -06:00
transmitter.cc Fix source typos (heirarchy->hierarchy) 2022-04-08 21:38:00 +02:00
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 Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
whitespace.cc Add a missing #include 2022-09-10 10:20:37 +01:00
windows_mmcss.cc Update core library GPL boilerplate and (C) from git log 2019-08-03 15:53:17 +02:00
windows_special_dirs.cc Fix minor memory leak when querying Windows registry 2021-10-11 18:20:07 +02:00
windows_timer_utils.cc window compilation fix 2021-06-26 18:40:44 -06:00
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