diff options
-rw-r--r-- | include/extensible.h | 2 | ||||
-rw-r--r-- | src/base.cpp | 4 | ||||
-rw-r--r-- | src/modules.cpp | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/include/extensible.h b/include/extensible.h index f327cf75c..bcc4992bb 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -101,7 +101,7 @@ class CoreExport ExtensionManager { std::map<std::string, reference<ExtensionItem> > types; public: - void Register(ExtensionItem* item); + bool Register(ExtensionItem* item); void BeginUnregister(Module* module, std::vector<reference<ExtensionItem> >& list); ExtensionItem* GetItem(const std::string& name); }; diff --git a/src/base.cpp b/src/base.cpp index bf74d9dc2..66a3cb140 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -132,9 +132,9 @@ void* ExtensionItem::unset_raw(Extensible* container) return rv; } -void ExtensionManager::Register(ExtensionItem* item) +bool ExtensionManager::Register(ExtensionItem* item) { - types.insert(std::make_pair(item->name, item)); + return types.insert(std::make_pair(item->name, item)).second; } void ExtensionManager::BeginUnregister(Module* module, std::vector<reference<ExtensionItem> >& list) diff --git a/src/modules.cpp b/src/modules.cpp index 1f135176c..4e4d20c70 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -448,7 +448,8 @@ void ModuleManager::AddService(ServiceProvider& item) throw ModuleException("Mode "+std::string(item.name)+" already exists."); return; case SERVICE_METADATA: - ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item)); + if (!ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item))) + throw ModuleException("Extension " + std::string(item.name) + " already exists."); return; case SERVICE_DATA: case SERVICE_IOHOOK: |