diff --git a/libs/ardour/test/test_ui.cc b/libs/ardour/test/test_ui.cc index 30687cd433..867eafba7d 100644 --- a/libs/ardour/test/test_ui.cc +++ b/libs/ardour/test/test_ui.cc @@ -37,7 +37,7 @@ TestUI::TestUI () pthread_set_name ("test_ui_thread"); - run_loop_thread = Glib::Threads::Thread::self (); + _run_loop_thread = PBD::Thread::self (); set_event_loop_for_thread (this); diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 7167eb3449..07b9aa4478 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -96,10 +96,9 @@ UI::UI (string application_name, string thread_name, int *argc, char ***argv) } /* the GUI event loop runs in the main thread of the app, - which is assumed to have called this. - */ - - run_loop_thread = Threads::Thread::self(); + * which is assumed to have called this. + */ + _run_loop_thread = PBD::Thread::self (); /* store "this" as the UI-for-thread of this thread, same argument as for previous line. @@ -144,9 +143,9 @@ UI::~UI () } bool -UI::caller_is_ui_thread () +UI::caller_is_ui_thread () const { - return Threads::Thread::self() == run_loop_thread; + return caller_is_self (); } int diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h index af3d29ed89..718c8cec74 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h +++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h @@ -129,7 +129,7 @@ public: /* Abstract UI interfaces */ - bool caller_is_ui_thread (); + bool caller_is_ui_thread () const; /* Gtk-UI specific interfaces */ diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index a4ea861c29..83df2b76b5 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -58,7 +58,7 @@ BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type(); BaseUI::BaseUI (const string& loop_name) : EventLoop (loop_name) , m_context(MainContext::get_default()) - , run_loop_thread (0) + , _run_loop_thread (0) , request_channel (true) { base_ui_instance = this; @@ -69,6 +69,7 @@ BaseUI::BaseUI (const string& loop_name) BaseUI::~BaseUI() { + delete _run_loop_thread; } BaseUI::RequestType @@ -121,7 +122,7 @@ BaseUI::run () attach_request_source (); Glib::Threads::Mutex::Lock lm (_run_lock); - run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread)); + _run_loop_thread = PBD::Thread::create (boost::bind (&BaseUI::main_thread, this)); _running.wait (_run_lock); } @@ -130,7 +131,7 @@ BaseUI::quit () { if (_main_loop && _main_loop->is_running()) { _main_loop->quit (); - run_loop_thread->join (); + _run_loop_thread->join (); } } diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index af501fc666..27bdb71644 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -53,8 +53,7 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop BaseUI* base_instance() { return base_ui_instance; } Glib::RefPtr main_loop() const { return _main_loop; } - Glib::Threads::Thread* event_loop_thread() const { return run_loop_thread; } - bool caller_is_self () const { return Glib::Threads::Thread::self() == run_loop_thread; } + bool caller_is_self () const { assert (_run_loop_thread); return _run_loop_thread->caller_is_self (); } bool ok() const { return _ok; } @@ -80,7 +79,7 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop Glib::RefPtr _main_loop; Glib::RefPtr m_context; - Glib::Threads::Thread* run_loop_thread; + PBD::Thread* _run_loop_thread; Glib::Threads::Mutex _run_lock; Glib::Threads::Cond _running;