summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/event.h10
-rw-r--r--include/modules.h6
2 files changed, 13 insertions, 3 deletions
diff --git a/include/event.h b/include/event.h
index 92bb4ffec..b00e44e38 100644
--- a/include/event.h
+++ b/include/event.h
@@ -122,6 +122,9 @@ class Events::ModuleEventListener : private dynamic_reference_base::CaptureHook
prov->subscribers.erase(this);
}
+ /** Retrieves the module which created this listener. */
+ const Module* GetModule() const { return prov.creator; }
+
friend struct ModuleEventProvider::Comp;
};
@@ -140,7 +143,9 @@ inline bool Events::ModuleEventProvider::Comp::operator()(Events::ModuleEventLis
for (::Events::ModuleEventProvider::SubscriberList::const_iterator _i = _handlers.begin(); _i != _handlers.end(); ++_i) \
{ \
listenerclass* _t = static_cast<listenerclass*>(*_i); \
- _t->func params ; \
+ const Module* _m = _t->GetModule(); \
+ if (_m && !_m->dying) \
+ _t->func params ; \
} \
} while (0);
@@ -157,6 +162,9 @@ inline bool Events::ModuleEventProvider::Comp::operator()(Events::ModuleEventLis
for (::Events::ModuleEventProvider::SubscriberList::const_iterator _i = _handlers.begin(); _i != _handlers.end(); ++_i) \
{ \
listenerclass* _t = static_cast<listenerclass*>(*_i); \
+ const Module* _m = _t->GetModule(); \
+ if (!_m || _m->dying) \
+ continue; \
result = _t->func params ; \
if (result != MOD_RES_PASSTHRU) \
break; \
diff --git a/include/modules.h b/include/modules.h
index 86d9d067d..45d2dd492 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -121,7 +121,8 @@ struct ModResult {
_next = _i+1; \
try \
{ \
- (*_i)->y x ; \
+ if (!(*_i)->dying) \
+ (*_i)->y x ; \
} \
catch (CoreException& modexcept) \
{ \
@@ -144,7 +145,8 @@ do { \
_next = _i+1; \
try \
{ \
- v = (*_i)->n args;
+ if (!(*_i)->dying) \
+ v = (*_i)->n args;
#define WHILE_EACH_HOOK(n) \
} \