diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-08-05 17:05:28 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-08-05 17:05:28 (GMT) |
commit | 9b335b8ef317430a7551a8f2cb86a98b4c330882 (patch) | |
tree | 0c0e843fb53f93e2a6088a07a4bb6e6f66483580 /Swiften/EventLoop | |
parent | 1873eca1f2147fa18f03fdd849fdd73d1a012be1 (diff) | |
download | swift-contrib-9b335b8ef317430a7551a8f2cb86a98b4c330882.zip swift-contrib-9b335b8ef317430a7551a8f2cb86a98b4c330882.tar.bz2 |
Swiften/LinkLocal: Avoid memory leak.
Diffstat (limited to 'Swiften/EventLoop')
-rw-r--r-- | Swiften/EventLoop/DummyEventLoop.h | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h index 234ecfa..7766bd4 100644 --- a/Swiften/EventLoop/DummyEventLoop.h +++ b/Swiften/EventLoop/DummyEventLoop.h @@ -1,7 +1,7 @@ -#ifndef SWIFTEN_DummyEventLoop_H -#define SWIFTEN_DummyEventLoop_H +#pragma once #include <deque> +#include <iostream> #include <boost/function.hpp> #include "Swiften/EventLoop/EventLoop.h" @@ -13,6 +13,13 @@ namespace Swift { DummyEventLoop() { } + ~DummyEventLoop() { + if (!events_.empty()) { + std::cerr << "DummyEventLoop: Unhandled events at destruction time" << std::endl; + } + events_.clear(); + } + void processEvents() { while (!events_.empty()) { handleEvent(events_[0]); @@ -20,9 +27,9 @@ namespace Swift { } } - bool hasEvents() { - return events_.size() > 0; - } + bool hasEvents() { + return events_.size() > 0; + } virtual void post(const Event& event) { events_.push_back(event); @@ -32,6 +39,3 @@ namespace Swift { std::deque<Event> events_; }; } - -#endif - |