summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-29 14:33:25 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-29 14:33:25 +0200
commit6c4a6b1753926f7de2cc210bf25d1b3c87c181e9 (patch)
treece7baa28bb5df3a10930b29d6c5cc8d4b1e520c0 /src
parentf9455b925dcccfed2accbeb282f82a9a3d8458f6 (diff)
Deduplicate mode unregistering code in ModuleManager::DoSafeUnload() and extract into a method
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 18f2dc4d1..567aa917c 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -342,6 +342,18 @@ bool ModuleManager::CanUnload(Module* mod)
return true;
}
+void ModuleManager::UnregisterModes(Module* mod, ModeType modetype)
+{
+ const ModeParser::ModeHandlerMap& modes = ServerInstance->Modes.GetModes(modetype);
+ for (ModeParser::ModeHandlerMap::const_iterator i = modes.begin(); i != modes.end(); )
+ {
+ ModeHandler* const mh = i->second;
+ ++i;
+ if (mh->creator == mod)
+ this->DelService(*mh);
+ }
+}
+
void ModuleManager::DoSafeUnload(Module* mod)
{
// First, notify all modules that a module is about to be unloaded, so in case
@@ -376,23 +388,8 @@ void ModuleManager::DoSafeUnload(Module* mod)
user->doUnhookExtensions(items);
}
- const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER);
- for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); )
- {
- ModeHandler* mh = i->second;
- ++i;
- if (mh->creator == mod)
- this->DelService(*mh);
- }
-
- const ModeParser::ModeHandlerMap& chanmodes = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
- for (ModeParser::ModeHandlerMap::const_iterator i = chanmodes.begin(); i != chanmodes.end(); )
- {
- ModeHandler* mh = i->second;
- ++i;
- if (mh->creator == mod)
- this->DelService(*mh);
- }
+ UnregisterModes(mod, MODETYPE_USER);
+ UnregisterModes(mod, MODETYPE_CHANNEL);
for(std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); )
{