diff options
author | Adam <Adam@anope.org> | 2015-07-13 17:59:14 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-07-13 17:59:14 -0400 |
commit | ceddb8370c85f5c5319b497a9c4efb578338beed (patch) | |
tree | c43b6a5d4ac515bf4492840b17aa63172a617d71 | |
parent | 4362f53cc38177039d6f6b86565e73800e7b5390 (diff) |
Unset extensibles on larger objects when they destruct
Some complex extensibles require the full object to still be alive in
their destructors to keep proper bookkeeping
-rw-r--r-- | include/extensible.h | 2 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/extensible.cpp | 5 | ||||
-rw-r--r-- | src/module.cpp | 2 | ||||
-rw-r--r-- | src/nickalias.cpp | 2 | ||||
-rw-r--r-- | src/nickcore.cpp | 2 | ||||
-rw-r--r-- | src/regchannel.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 2 |
8 files changed, 19 insertions, 0 deletions
diff --git a/include/extensible.h b/include/extensible.h index 2a852ff47..c9787fd21 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -40,6 +40,8 @@ class CoreExport Extensible virtual ~Extensible(); + void UnsetExtensibles(); + template<typename T> T* GetExt(const Anope::string &name) const; bool HasExt(const Anope::string &name) const; diff --git a/src/channels.cpp b/src/channels.cpp index 7e7702d7e..5a578b300 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -52,6 +52,8 @@ Channel::Channel(const Anope::string &nname, time_t ts) Channel::~Channel() { + UnsetExtensibles(); + FOREACH_MOD(OnChannelDelete, (this)); ModeManager::StackerDel(this); diff --git a/src/extensible.cpp b/src/extensible.cpp index 37206f7c1..50a23101a 100644 --- a/src/extensible.cpp +++ b/src/extensible.cpp @@ -24,6 +24,11 @@ ExtensibleBase::~ExtensibleBase() Extensible::~Extensible() { + UnsetExtensibles(); +} + +void Extensible::UnsetExtensibles() +{ while (!extension_items.empty()) (*extension_items.begin())->Unset(this); } diff --git a/src/module.cpp b/src/module.cpp index 3266c955f..5c02e4e49 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -64,6 +64,8 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt Module::~Module() { + UnsetExtensibles(); + /* Detach all event hooks for this module */ ModuleManager::DetachAll(this); IdentifyRequest::ModuleUnload(this); diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 9f3651c12..fbf3411fc 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -51,6 +51,8 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Serial NickAlias::~NickAlias() { + UnsetExtensibles(); + FOREACH_MOD(OnDelNick, (this)); /* Accept nicks that have no core, because of database load functions */ diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 9c0e25f32..f669a9181 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -38,6 +38,8 @@ NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), NickCore::~NickCore() { + UnsetExtensibles(); + FOREACH_MOD(OnDelCore, (this)); if (!this->chanaccess->empty()) diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 397a6f28b..2b17c72ca 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -142,6 +142,8 @@ ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"), ChannelInfo::~ChannelInfo() { + UnsetExtensibles(); + FOREACH_MOD(OnDelChan, (this)); Log(LOG_DEBUG) << "Deleting channel " << this->name; diff --git a/src/users.cpp b/src/users.cpp index 8ec13d8c0..73d1d4368 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -292,6 +292,8 @@ void User::SetRealname(const Anope::string &srealname) User::~User() { + UnsetExtensibles(); + if (this->server != NULL) { if (this->server->IsSynced()) |