summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 03d0b5269..144ddee72 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -11,8 +11,6 @@
* ---------------------------------------------------
*/
-/* $Core */
-
#include "inspircd.h"
#include "inspstring.h"
@@ -55,10 +53,16 @@ ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modelett
{
}
+bool ModeHandler::cull()
+{
+ ServerInstance->Modes->DelMode(this);
+ return true;
+}
+
ModeHandler::~ModeHandler()
{
- if (ServerInstance)
- ServerInstance->Modes->DelMode(this);
+ if (ServerInstance && ServerInstance->Modes->FindMode(mode, m_type) == this)
+ ServerInstance->Logs->Log("MODE", DEBUG, "ERROR: Destructor for mode %c called while not culled", mode);
}
bool ModeHandler::IsListMode()
@@ -660,7 +664,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
mh->GetModeType() == MODETYPE_USER ? mask = MASK_USER : mask = MASK_CHANNEL;
pos = (mh->GetModeChar()-65) | mask;
- if (!modehandlers[pos])
+ if (modehandlers[pos] != mh)
return false;
/* Note: We can't stack here, as we have modes potentially being removed across many different channels.
@@ -1023,6 +1027,6 @@ ModeParser::ModeParser()
ModeParser::~ModeParser()
{
ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
- if (mh)
+ if (mh && mh->cull())
delete mh;
}