From 37969d837e16c8fbac0821074495b5ebc2297d94 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 14 May 2012 17:07:53 +0000 Subject: remove virtual inheritance of sigc::trackable by Receiver and AbstractUI, done by changing Gtkmm2ext::UI to use composition (HAS-A) rather than inheritance (IS-A) for Receiver; use correct synchronization when starting up a BseUI event loop thread so that tests that start/stop quickly do not encounter a race condition git-svn-id: svn://localhost/ardour2/branches/3.0@12264 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/base_ui.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libs/pbd/base_ui.cc') diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 31f956f4cf..c246a50656 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -74,11 +74,22 @@ void BaseUI::main_thread () { DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_self())); + std::cerr << string_compose ("%1: event loop running in thread %2\n", name(), pthread_self()); set_event_loop_for_thread (this); thread_init (); + _main_loop->get_context()->signal_idle().connect (sigc::mem_fun (*this, &BaseUI::signal_running)); _main_loop->run (); } +bool +BaseUI::signal_running () +{ + Glib::Mutex::Lock lm (_run_lock); + _running.signal (); + + return false; // don't call it again +} + void BaseUI::run () { @@ -91,7 +102,11 @@ BaseUI::run () /* glibmm hack - drop the refptr to the IOSource now before it can hurt */ request_channel.drop_ios (); + Glib::Mutex::Lock lm (_run_lock); run_loop_thread = Thread::create (mem_fun (*this, &BaseUI::main_thread), true); + std::cerr << "wait for " << name() << " thread to start\n"; + _running.wait (_run_lock); + std::cerr << "\tthread now running\n"; } void -- cgit v1.2.3