1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Merge pull request #5658 from IvanSavenko/memleak_fix

Fix discovered memory leaks & reduce usage of raw pointers
This commit is contained in:
Ivan Savenko
2025-04-30 13:38:37 +03:00
committed by GitHub
45 changed files with 258 additions and 240 deletions

View File

@@ -71,7 +71,7 @@ static std::string getModDirectory(const TModID & modName)
return "MODS/" + result;
}
static ISimpleResourceLoader * genModFilesystem(const std::string & modName, const JsonNode & conf)
static std::unique_ptr<ISimpleResourceLoader> genModFilesystem(const std::string & modName, const JsonNode & conf)
{
static const JsonNode defaultFS = genDefaultFS();
@@ -87,20 +87,20 @@ void CModHandler::loadModFilesystems()
const auto & activeMods = modManager->getActiveMods();
std::map<TModID, ISimpleResourceLoader *> modFilesystems;
std::map<TModID, std::unique_ptr<ISimpleResourceLoader>> modFilesystems;
for(const TModID & modName : activeMods)
modFilesystems[modName] = genModFilesystem(modName, getModInfo(modName).getFilesystemConfig());
for(const TModID & modName : activeMods)
if (modName != "core") // virtual mod 'core' has no filesystem on its own - shared with base install
CResourceHandler::addFilesystem("data", modName, modFilesystems[modName]);
if (settings["mods"]["validation"].String() == "full")
checkModFilesystemsConflicts(modFilesystems);
for(const TModID & modName : activeMods)
if (modName != "core") // virtual mod 'core' has no filesystem on its own - shared with base install
CResourceHandler::addFilesystem("data", modName, std::move(modFilesystems[modName]));
}
void CModHandler::checkModFilesystemsConflicts(const std::map<TModID, ISimpleResourceLoader *> & modFilesystems)
void CModHandler::checkModFilesystemsConflicts(const std::map<TModID, std::unique_ptr<ISimpleResourceLoader>> & modFilesystems)
{
for(const auto & [leftName, leftFilesystem] : modFilesystems)
{

View File

@@ -27,7 +27,7 @@ class DLL_LINKAGE CModHandler final : boost::noncopyable
std::set<std::string> validationPassed;
void loadTranslation(const TModID & modName);
void checkModFilesystemsConflicts(const std::map<TModID, ISimpleResourceLoader *> & modFilesystems);
void checkModFilesystemsConflicts(const std::map<TModID, std::unique_ptr<ISimpleResourceLoader>> & modFilesystems);
bool isModValidationNeeded(const ModDescription & mod) const;