mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 05:13:59 +02:00
- fixed memory leaks in map editor, g3dviewer and the game
This commit is contained in:
@@ -99,6 +99,8 @@ public:
|
||||
* can be read or not depending on the file content*/
|
||||
virtual bool canRead(ifstream& file) const;
|
||||
|
||||
virtual void cleanupExtensions();
|
||||
|
||||
/**Reads a file
|
||||
* This method tries to read the file with the specified filepath
|
||||
* If it fails, either <code>null</code> is returned or an exception
|
||||
@@ -137,6 +139,7 @@ public:
|
||||
virtual T* read(ifstream& file, const string& path, T* former) const = 0;
|
||||
|
||||
virtual ~FileReader() {
|
||||
cleanupExtensions();
|
||||
}; //Well ... these objects aren't supposed to be destroyed
|
||||
};
|
||||
|
||||
@@ -283,6 +286,18 @@ FileReader<T>::FileReader(std::vector<string> extensions): extensions(extensions
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void FileReader<T>::cleanupExtensions() {
|
||||
std::vector<string> nextExtension = extensions;
|
||||
for(unsigned int i = 0; i < nextExtension.size(); ++i) {
|
||||
vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]];
|
||||
if (curPossibleReaders != NULL) {
|
||||
delete curPossibleReaders;
|
||||
(getFileReadersMap())[nextExtension[i]] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**Gives a quick estimation of whether the specified file
|
||||
* can be read or not depending on the filename*/
|
||||
template <typename T>
|
||||
|
Reference in New Issue
Block a user