From d5ad9ff033867f3d28914ba3315b2504fa8685ee Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 23 Aug 2023 12:14:38 -0600 Subject: [PATCH] libpbd/guis: move __invalidator() into PBD::EventLoop we allow use of/dependency on sigc::trackable there, so this is both legal but also sensible. Leave the macro definition of invalidator(x) in gtkmm2ext/gui_thread.h because it doesn't hurt and makes some sense for it to be there. No reason for a source module that needs invalidator(x) to load EventLoop decl. --- libs/gtkmm2ext/gtk_ui.cc | 17 ----------------- libs/gtkmm2ext/gtkmm2ext/gui_thread.h | 3 +-- libs/pbd/event_loop.cc | 19 +++++++++++++++++++ libs/pbd/pbd/event_loop.h | 4 +++- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index f6acfab981..af9d2bd198 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -456,23 +456,6 @@ UI::idle_add (int (*func)(void *), void *arg) /* END abstract_ui interfaces */ -/** Create a PBD::EventLoop::InvalidationRecord and attach a callback - * to a given sigc::trackable so that PBD::EventLoop::invalidate_request - * is called when that trackable is destroyed. - */ -PBD::EventLoop::InvalidationRecord* -__invalidator (sigc::trackable& trackable, const char* file, int line) -{ - PBD::EventLoop::InvalidationRecord* ir = new PBD::EventLoop::InvalidationRecord; - - ir->file = file; - ir->line = line; - - trackable.add_destroy_notify_callback (ir, PBD::EventLoop::invalidate_request); - - return ir; -} - void UI::do_request (UIRequest* req) { diff --git a/libs/gtkmm2ext/gtkmm2ext/gui_thread.h b/libs/gtkmm2ext/gtkmm2ext/gui_thread.h index 66c381c073..63786ed90f 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gui_thread.h +++ b/libs/gtkmm2ext/gtkmm2ext/gui_thread.h @@ -35,7 +35,6 @@ namespace sigc { #define gui_context() Gtkmm2ext::UI::instance() /* a UICallback-derived object that specifies the event loop for GUI signal handling */ #define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) -LIBGTKMM2EXT_API extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int); -#define invalidator(x) __invalidator ((x), __FILE__, __LINE__) +#define invalidator(x) PBD::EventLoop::__invalidator ((x), __FILE__, __LINE__) #endif /* __ardour_gtk_gui_thread_h__ */ diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc index 97a6dc4ee0..a0dae62fef 100644 --- a/libs/pbd/event_loop.cc +++ b/libs/pbd/event_loop.cc @@ -109,6 +109,24 @@ EventLoop::invalidate_request (void* data) return 0; } +/** Create a PBD::EventLoop::InvalidationRecord and attach a callback + * to a given sigc::trackable so that PBD::EventLoop::invalidate_request + * is called when that trackable is destroyed. + */ +EventLoop::InvalidationRecord* +EventLoop::__invalidator (sigc::trackable& trackable, const char* file, int line) +{ + PBD::EventLoop::InvalidationRecord* ir = new PBD::EventLoop::InvalidationRecord; + + ir->file = file; + ir->line = line; + + trackable.add_destroy_notify_callback (ir, PBD::EventLoop::invalidate_request); + + return ir; +} + + vector EventLoop::get_request_buffers_for_target_thread (const std::string& target_thread) { @@ -197,3 +215,4 @@ EventLoop::remove_request_buffer_from_map (pthread_t pth) } } } + diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h index 5f24bbeeba..48df8620df 100644 --- a/libs/pbd/pbd/event_loop.h +++ b/libs/pbd/pbd/event_loop.h @@ -109,6 +109,8 @@ public: std::list trash; + static InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int); + private: static Glib::Threads::Private thread_event_loop; std::string _name; @@ -136,6 +138,6 @@ private: } -#define MISSING_INVALIDATOR 0 // used to mark places where we fail to provide an invalidator +#define MISSING_INVALIDATOR nullptr // used to mark places where we fail to provide an invalidator #endif /* __pbd_event_loop_h__ */