Fix warning: delete called on non-final that has virtual functions but non-virtual destructor (#1671)

This commit is contained in:
privatecore
2025-09-28 13:53:11 +02:00
committed by GitHub
parent 30bd58be67
commit b0f3de65f5

View File

@@ -47,6 +47,8 @@ public:
std::unordered_map<std::string, ObjectCreator> creators; std::unordered_map<std::string, ObjectCreator> creators;
public: public:
virtual ~NamedObjectFactory() = default;
virtual T* create(std::string name, PlayerbotAI* botAI) virtual T* create(std::string name, PlayerbotAI* botAI)
{ {
size_t found = name.find("::"); size_t found = name.find("::");
@@ -147,10 +149,8 @@ public:
{ {
contexts.push_back(context); contexts.push_back(context);
for (const auto& iter : context->creators) for (const auto& iter : context->creators)
{
creators[iter.first] = iter.second; creators[iter.first] = iter.second;
} }
}
}; };
template <class T> template <class T>
@@ -208,6 +208,7 @@ public:
if (T* object = create(name, botAI)) if (T* object = create(name, botAI))
return created[name] = object; return created[name] = object;
} }
return created[name]; return created[name];
} }
@@ -236,7 +237,6 @@ public:
for (auto i = contexts.begin(); i != contexts.end(); i++) for (auto i = contexts.begin(); i != contexts.end(); i++)
{ {
std::set<std::string> supported = (*i)->supports(); std::set<std::string> supported = (*i)->supports();
for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j) for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j)
result.insert(*j); result.insert(*j);
} }
@@ -248,9 +248,7 @@ public:
{ {
std::set<std::string> result; std::set<std::string> result;
for (typename std::unordered_map<std::string, T*>::const_iterator i = created.begin(); i != created.end(); i++) for (typename std::unordered_map<std::string, T*>::const_iterator i = created.begin(); i != created.end(); i++)
{
result.insert(i->first); result.insert(i->first);
}
return result; return result;
} }
@@ -297,15 +295,14 @@ public:
{ {
factories.push_back(context); factories.push_back(context);
for (const auto& iter : context->creators) for (const auto& iter : context->creators)
{
creators[iter.first] = iter.second; creators[iter.first] = iter.second;
} }
}
T* GetContextObject(const std::string& name, PlayerbotAI* botAI) T* GetContextObject(const std::string& name, PlayerbotAI* botAI)
{ {
if (T* object = create(name, botAI)) if (T* object = create(name, botAI))
return object; return object;
return nullptr; return nullptr;
} }
}; };