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.
This commit is contained in:
James Turner
2020-06-17 11:48:59 +01:00
parent b4d5374fb7
commit aa0f02706f
2 changed files with 15 additions and 2 deletions
+11
View File
@@ -56,6 +56,15 @@ ResourceManager::~ResourceManager()
std::for_each(_providers.begin(), _providers.end(), std::for_each(_providers.begin(), _providers.end(),
[](ResourceProvider* p) { delete p; }); [](ResourceProvider* p) { delete p; });
} }
void ResourceManager::reset()
{
if (static_manager) {
delete static_manager;
static_manager = nullptr;
}
}
/** /**
* trivial provider using a fixed base path * 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"); SG_LOG(SG_GENERAL, SG_DEV_ALERT, "unknown provider doing remove");
return; return;
} }
_providers.erase(it);
} }
SGPath ResourceManager::findPath(const std::string& aResource, SGPath aContext) SGPath ResourceManager::findPath(const std::string& aResource, SGPath aContext)
+2
View File
@@ -47,6 +47,8 @@ public:
static ResourceManager* instance(); static ResourceManager* instance();
static void reset();
/** /**
* add a simple fixed resource location, to resolve against * add a simple fixed resource location, to resolve against
*/ */