1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00

Close #13000: Refactor ObjectFactory to use unique_ptr

Employs the smart pointer unique_ptr for safer memory management.

Classes involved:
 - ObjectRepository
 - ObjectManager
This commit is contained in:
Vinicius Sa
2020-10-14 16:56:48 -03:00
committed by GitHub
parent 0c283ba3e7
commit 711dd00cde
11 changed files with 129 additions and 163 deletions

View File

@@ -193,7 +193,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::LoadObjectIm
auto obj = ObjectFactory::CreateObjectFromLegacyFile(context->GetObjectRepository(), objectPath.c_str());
if (obj != nullptr)
{
auto& imgTable = static_cast<const Object*>(obj)->GetImageTable();
auto& imgTable = static_cast<const Object*>(obj.get())->GetImageTable();
auto numImages = static_cast<int32_t>(imgTable.GetCount());
auto images = imgTable.GetImages();
size_t placeHoldersAdded = 0;
@@ -210,7 +210,6 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::LoadObjectIm
placeHoldersAdded++;
}
}
delete obj;
// Log place holder information
if (placeHoldersAdded > 0)