summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-18 20:10:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-18 20:27:37 (GMT)
commit0d3d7579032959203c5c52f5ced9de5494c7b0bf (patch)
tree1e166cbae3dac23e8f815bc32f856b6c0a666fbd /Swiften/EventLoop/EventLoop.cpp
parentc2580661a20e30abaa23c61808d6370a575665c1 (diff)
downloadswift-0d3d7579032959203c5c52f5ced9de5494c7b0bf.zip
swift-0d3d7579032959203c5c52f5ced9de5494c7b0bf.tar.bz2
Cleaned up some code.
Diffstat (limited to 'Swiften/EventLoop/EventLoop.cpp')
-rw-r--r--Swiften/EventLoop/EventLoop.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp
index f787e73..c6d42d8 100644
--- a/Swiften/EventLoop/EventLoop.cpp
+++ b/Swiften/EventLoop/EventLoop.cpp
@@ -10,6 +10,8 @@
#include <boost/bind.hpp>
#include <iostream>
+#include <Swiften/Base/Log.h>
+
namespace Swift {
EventLoop::EventLoop() : nextEventID_(0), handlingEvents_(false) {
@@ -37,13 +39,24 @@ void EventLoop::handleEvent(const Event& event) {
}
if (doCallback) {
handlingEvents_ = true;
- event.callback();
+ try {
+ event.callback();
+ }
+ catch (const boost::bad_function_call&) {
+ SWIFT_LOG(error) << "Invalid function call" << std::endl;
+ }
+
// Process events that were passed to handleEvent during the callback
// (i.e. through recursive calls of handleEvent)
while (!eventsToHandle_.empty()) {
Event nextEvent = eventsToHandle_.front();
eventsToHandle_.pop_front();
- nextEvent.callback();
+ try {
+ nextEvent.callback();
+ }
+ catch (const boost::bad_function_call&) {
+ SWIFT_LOG(error) << "Invalid function call" << std::endl;
+ }
}
handlingEvents_ = false;
}