1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +02:00

Use unique_ptr instead of raw pointers to attempt to fix crash on free

This commit is contained in:
Ivan Savenko
2023-12-16 13:42:12 +02:00
parent 5f4608c9f0
commit 1acab80fdc
2 changed files with 19 additions and 23 deletions

View File

@ -68,7 +68,7 @@ public:
class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
{
/// list of object handlers, each of them handles only one type
std::vector<ObjectClass * > objects;
std::vector< std::unique_ptr<ObjectClass> > objects;
/// map that is filled during contruction with all known handlers. Not serializeable due to usage of std::function
std::map<std::string, std::function<TObjectTypeHandler()> > handlerConstructors;
@ -82,7 +82,7 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
void loadSubObject(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * obj);
void loadSubObject(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * obj, size_t index);
ObjectClass * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & name, size_t index);
std::unique_ptr<ObjectClass> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & name, size_t index);
void generateExtraMonolithsForRMG(ObjectClass * container);