From aa0f02706ffb080cd81cc4eb7e3c45c1be700411 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 17 Jun 2020 11:19:20 +0100 Subject: [PATCH] API to reset the resource manager, and remove providers. Needed to fix a bug with parsing -set.xml files in the launcher; correctly loading XML needs the resource paths to be defined. --- simgear/misc/ResourceManager.cxx | 11 +++++++++++ simgear/misc/ResourceManager.hxx | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/simgear/misc/ResourceManager.cxx b/simgear/misc/ResourceManager.cxx index 11b67846..59454dce 100644 --- a/simgear/misc/ResourceManager.cxx +++ b/simgear/misc/ResourceManager.cxx @@ -56,6 +56,15 @@ ResourceManager::~ResourceManager() std::for_each(_providers.begin(), _providers.end(), [](ResourceProvider* p) { delete p; }); } + +void ResourceManager::reset() +{ + if (static_manager) { + delete static_manager; + static_manager = nullptr; + } +} + /** * trivial provider using a fixed base path */ @@ -107,6 +116,8 @@ void ResourceManager::removeProvider(ResourceProvider* aProvider) SG_LOG(SG_GENERAL, SG_DEV_ALERT, "unknown provider doing remove"); return; } + + _providers.erase(it); } SGPath ResourceManager::findPath(const std::string& aResource, SGPath aContext) diff --git a/simgear/misc/ResourceManager.hxx b/simgear/misc/ResourceManager.hxx index a15aaf15..b957f0de 100644 --- a/simgear/misc/ResourceManager.hxx +++ b/simgear/misc/ResourceManager.hxx @@ -45,8 +45,10 @@ public: PRIORITY_HIGH = 1000 } Priority; - static ResourceManager* instance(); - + static ResourceManager* instance(); + + static void reset(); + /** * add a simple fixed resource location, to resolve against */