From b0f3de65f55cfd3f817a51c3c2fc23143321a89b Mon Sep 17 00:00:00 2001 From: privatecore Date: Sun, 28 Sep 2025 13:53:11 +0200 Subject: [PATCH] Fix warning: delete called on non-final that has virtual functions but non-virtual destructor (#1671) --- src/strategy/NamedObjectContext.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/strategy/NamedObjectContext.h b/src/strategy/NamedObjectContext.h index 69b38ce1..846026c2 100644 --- a/src/strategy/NamedObjectContext.h +++ b/src/strategy/NamedObjectContext.h @@ -47,6 +47,8 @@ public: std::unordered_map creators; public: + virtual ~NamedObjectFactory() = default; + virtual T* create(std::string name, PlayerbotAI* botAI) { size_t found = name.find("::"); @@ -147,9 +149,7 @@ public: { contexts.push_back(context); for (const auto& iter : context->creators) - { creators[iter.first] = iter.second; - } } }; @@ -208,6 +208,7 @@ public: if (T* object = create(name, botAI)) return created[name] = object; } + return created[name]; } @@ -236,7 +237,6 @@ public: for (auto i = contexts.begin(); i != contexts.end(); i++) { std::set supported = (*i)->supports(); - for (std::set::const_iterator j = supported.begin(); j != supported.end(); ++j) result.insert(*j); } @@ -248,9 +248,7 @@ public: { std::set result; for (typename std::unordered_map::const_iterator i = created.begin(); i != created.end(); i++) - { result.insert(i->first); - } return result; } @@ -297,15 +295,14 @@ public: { factories.push_back(context); for (const auto& iter : context->creators) - { creators[iter.first] = iter.second; - } } T* GetContextObject(const std::string& name, PlayerbotAI* botAI) { if (T* object = create(name, botAI)) return object; + return nullptr; } };