13
0
livetrax/libs/pbd/event_loop.cc
Carl Hetherington 8a8552c4cb Allow cross-thread request invalidators to cope with multiple requests
being logged before they are handled, and to invalidate them all rather
than just the last one.  Fixes shutdown problems when the PortMatrix has
been opened during the session, during which PortRegisteredOrUnregistered
is emitted quite heavily.


git-svn-id: svn://localhost/ardour2/branches/3.0@6852 d708f5d6-7413-0410-9779-e7cbd77b26cf
2010-04-03 00:42:39 +00:00

46 lines
1.1 KiB
C++

#include <iostream>
#include "pbd/event_loop.h"
#include "pbd/stacktrace.h"
using namespace PBD;
using namespace std;
Glib::StaticPrivate<EventLoop> EventLoop::thread_event_loop;
static void do_not_delete_the_loop_pointer (void*) { }
EventLoop*
EventLoop::get_event_loop_for_thread() {
return thread_event_loop.get ();
}
void
EventLoop::set_event_loop_for_thread (EventLoop* loop)
{
thread_event_loop.set (loop, do_not_delete_the_loop_pointer);
}
/** Called when a sigc::trackable that was connected to using the invalidator() macro
* is destroyed.
*/
void*
EventLoop::invalidate_request (void* data)
{
InvalidationRecord* ir = (InvalidationRecord*) data;
if (ir->event_loop) {
Glib::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
cerr << "Object deleted had outstanding event loop request, IR created @ "
<< ir->file << ':' << ir->line
<< endl;
(*i)->valid = false;
(*i)->invalidation = 0;
}
delete ir;
}
return 0;
}