mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
Fixed a nasty order of destruction bug, where the memory pool for ScriptInts was destroyed before the PackageManager
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@20 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -28,11 +28,11 @@ class PackageManager {
|
||||
/// Open a package with the specified name (including extension)
|
||||
template <typename T>
|
||||
shared_ptr<T> open(const String& name) {
|
||||
wxFileName fn(dataDirectory + _("/") + name);
|
||||
wxFileName fn(data_directory + _("/") + name);
|
||||
fn.Normalize();
|
||||
String filename = fn.GetFullPath();
|
||||
// Is this package already loaded?
|
||||
PackagedP& p = loadedPackages[filename];
|
||||
PackagedP& p = loaded_packages[filename];
|
||||
shared_ptr<T> typedP = dynamic_pointer_cast<T>(p);
|
||||
if (typedP) {
|
||||
return typedP;
|
||||
@@ -48,9 +48,14 @@ class PackageManager {
|
||||
/// the type of package is determined by its extension!
|
||||
PackagedP openAnyPackage(const String& filename);
|
||||
|
||||
/// Empty the list of packages.
|
||||
/** This function MUST be called before the program terminates, otherwise
|
||||
* we could get into fights with pool allocators used by ScriptValues */
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
map<String, PackagedP> loadedPackages;
|
||||
String dataDirectory;
|
||||
map<String, PackagedP> loaded_packages;
|
||||
String data_directory;
|
||||
};
|
||||
|
||||
/// The global PackageManager instance
|
||||
|
||||
Reference in New Issue
Block a user