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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,8 @@ public:
std::unordered_map<std::string, ObjectCreator> creators;
public:
virtual ~NamedObjectFactory() = default;
virtual T* create(std::string name, PlayerbotAI* botAI)
{
size_t found = name.find("::");
@ -147,10 +149,8 @@ public:
{
contexts.push_back(context);
for (const auto& iter : context->creators)
{
creators[iter.first] = iter.second;
}
}
};
template <class T>
@ -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<std::string> supported = (*i)->supports();
for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j)
result.insert(*j);
}
@ -248,9 +248,7 @@ public:
{
std::set<std::string> result;
for (typename std::unordered_map<std::string, T*>::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;
}
};