diff options
Diffstat (limited to 'common/EventDispatcher.cpp')
-rw-r--r-- | common/EventDispatcher.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp index 012a2dfce5..dc123e8f8f 100644 --- a/common/EventDispatcher.cpp +++ b/common/EventDispatcher.cpp @@ -38,7 +38,9 @@ EventDispatcher::~EventDispatcher() { delete i->observer; } - delete _mapper; + if (_autoFreeMapper) { + delete _mapper; + } _mapper = 0; } @@ -68,11 +70,15 @@ void EventDispatcher::dispatch() { } } -void EventDispatcher::registerMapper(EventMapper *mapper) { - delete _mapper; +void EventDispatcher::registerMapper(EventMapper *mapper, bool autoFree) { + if (_autoFreeMapper) { + delete _mapper; + } _mapper = mapper; + _autoFreeMapper = autoFree; } + void EventDispatcher::registerSource(EventSource *source, bool autoFree) { SourceEntry newEntry; |