Changeset - a1d9abd984c5
[Not reviewed]
0 2 0
Jan Kaluza - 14 years ago 2011-08-17 18:50:59
hanzz.k@gmail.com
handle and destroy those frigging event loops, all, god, 4 hours....
2 files changed with 12 insertions and 3 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/spectrumeventloop.cpp
Show inline comments
 
@@ -30,16 +30,18 @@
 

	
 
using namespace Swift;
 

	
 
static SpectrumEventLoop *loop;
 

	
 
// Fires the event's callback and frees the event
 
static gboolean processEvent(void *data) {
 
	Event *ev = (Event *) data;
 
	ev->callback();
 
	delete ev;
 
	loop->handle(ev);
 
	return FALSE;
 
}
 

	
 
SpectrumEventLoop::SpectrumEventLoop() : m_isRunning(false) {
 
	m_loop = NULL;
 
	loop = this;
 
	if (true) {
 
		m_loop = g_main_loop_new(NULL, FALSE);
 
	}
 
@@ -67,6 +69,11 @@ void SpectrumEventLoop::run() {
 
#endif
 
}
 

	
 
void SpectrumEventLoop::handle(Swift::Event *event) {
 
	handleEvent(*event);
 
	delete event;
 
}
 

	
 
void SpectrumEventLoop::stop() {
 
	std::cout << "stopped loop\n";
 
	if (!m_isRunning)
 
@@ -85,6 +92,6 @@ void SpectrumEventLoop::stop() {
 

	
 
void SpectrumEventLoop::post(const Event& event) {
 
	// pass copy of event to main thread
 
	Event *ev = new Event(event.owner, event.callback);
 
	Event *ev = new Event(event);
 
	purple_timeout_add(0, processEvent, ev);
 
}
backends/libpurple/spectrumeventloop.h
Show inline comments
 
@@ -38,6 +38,8 @@ class SpectrumEventLoop : public Swift::EventLoop {
 
		// Stops tht eventloop.
 
		void stop();
 

	
 
		void handle(Swift::Event *event);
 

	
 
		// Posts new Swift::Event to main thread.
 
		virtual void post(const Swift::Event& event);
 

	
0 comments (0 inline, 0 general)