(re)add mechanism for a callback in any glib event loop executed before the loop "executes"

This is based on code from earlier commits that were later reversed, but we need some mechanism
to ensure that threads have a thread local tempo map ptr set. The big difference is that this
time we do not implement this for all instances of an AbstractUI - implementation is left to
each thread/event loop
This commit is contained in:
Paul Davis 2022-05-16 15:23:42 -06:00
parent 2079a150dd
commit 968533cc23
5 changed files with 57 additions and 0 deletions

View File

@ -175,5 +175,6 @@ BaseUI::attach_request_source ()
{
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name()));
request_channel.attach (m_context);
maybe_install_precall_handler (m_context);
}

View File

@ -0,0 +1,19 @@
#include "pbd/glib_event_source.h"
bool
GlibEventLoopSource::prepare (int& timeout)
{
return false;
}
bool
GlibEventLoopSource::check ()
{
return false;
}
bool
GlibEventLoopSource::dispatch (sigc::slot_base*)
{
return false;
}

View File

@ -105,6 +105,8 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
void signal_new_request ();
void attach_request_source ();
virtual void maybe_install_precall_handler (Glib::RefPtr<Glib::MainContext>) {}
/** Derived UI objects must implement this method,
* which will be called whenever there are requests
* to be dealt with.

View File

@ -0,0 +1,34 @@
#ifndef __libpbd_glib_event_source_h__
#define __libpbd_glib_event_source_h__
#include <boost/function.hpp>
#include <glibmm/main.h>
#include "pbd/libpbd_visibility.h"
class LIBPBD_API GlibEventLoopSource : public Glib::Source
{
public:
GlibEventLoopSource () {};
bool prepare (int& timeout);
bool check();
bool dispatch (sigc::slot_base*);
};
class LIBPBD_API GlibEventLoopCallback : public GlibEventLoopSource
{
public:
GlibEventLoopCallback (boost::function<void()> callback) : _callback (callback) {}
bool check() {
_callback();
return false;
}
private:
boost::function<void()> _callback;
};
#endif /* __libpbd_glib_event_source_h__ */

View File

@ -51,6 +51,7 @@ libpbd_sources = [
'file_archive.cc',
'file_utils.cc',
'fpu.cc',
'glib_event_source.cc',
'id.cc',
'locale_guard.cc',
'localtime_r.cc',