1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix memory leaks in launcher.

This commit is contained in:
Karlis Senko 2018-04-28 11:56:01 +03:00
parent 7fb7ceaad7
commit 40e6292ed2
6 changed files with 12 additions and 19 deletions

View File

@ -985,7 +985,6 @@ void dispose()
}
// cleanup, mostly to remove false leaks from analyzer
CResourceHandler::clear();
if(CCS)
{
CCS->musich->release();

View File

@ -24,13 +24,13 @@
void CModListView::setupModModel()
{
modModel = new CModListModel();
manager = new CModManager(modModel);
modModel = new CModListModel(this);
manager = vstd::make_unique<CModManager>(modModel);
}
void CModListView::setupFilterModel()
{
filterModel = new CModFilterModel(modModel);
filterModel = new CModFilterModel(modModel, this);
filterModel->setFilterKeyColumn(-1); // filter across all columns
filterModel->setSortCaseSensitivity(Qt::CaseInsensitive); // to make it more user-friendly

View File

@ -29,7 +29,7 @@ class CModListView : public QWidget
{
Q_OBJECT
CModManager * manager;
std::unique_ptr<CModManager> manager;
CModListModel * modModel;
CModFilterModel * filterModel;
CDownloadManager * dlManager;

View File

@ -22,6 +22,7 @@
#include "../CStopWatch.h"
std::map<std::string, ISimpleResourceLoader*> CResourceHandler::knownLoaders = std::map<std::string, ISimpleResourceLoader*>();
CResourceHandler CResourceHandler::globalResourceHandler;
CFilesystemGenerator::CFilesystemGenerator(std::string prefix):
filesystem(new CFilesystemList()),
@ -117,11 +118,6 @@ void CFilesystemGenerator::loadJsonMap(const std::string &mountPoint, const Json
}
}
void CResourceHandler::clear()
{
delete knownLoaders["root"];
}
ISimpleResourceLoader * CResourceHandler::createInitial()
{
//temporary filesystem that will be used to initialize main one.
@ -174,7 +170,8 @@ void CResourceHandler::initialize()
// |-saves
// |-config
knownLoaders["root"] = new CFilesystemList();
globalResourceHandler.rootLoader = vstd::make_unique<CFilesystemList>();
knownLoaders["root"] = globalResourceHandler.rootLoader.get();
knownLoaders["saves"] = new CFilesystemLoader("SAVES/", VCMIDirs::get().userSavePath());
knownLoaders["config"] = new CFilesystemLoader("CONFIG/", VCMIDirs::get().userConfigPath());

View File

@ -75,13 +75,6 @@ public:
*/
static void initialize();
/**
* Semi-debug method to track all possible cases of memory leaks
* Used before exiting application
*
*/
static void clear();
/**
* Will load all filesystem data from Json data at this path (normally - config/filesystem.json)
* @param fsConfigURI - URI from which data will be loaded
@ -103,7 +96,12 @@ public:
*/
static ISimpleResourceLoader * createFileSystem(const std::string &prefix, const JsonNode & fsConfig);
~CResourceHandler() = default;
private:
/** Instance of resource loader */
static std::map<std::string, ISimpleResourceLoader*> knownLoaders;
static CResourceHandler globalResourceHandler;
CResourceHandler() {};
std::unique_ptr<ISimpleResourceLoader> rootLoader;
};

View File

@ -945,7 +945,6 @@ int main(int argc, char * argv[])
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "killServer");
#endif
vstd::clear_pointer(VLC);
CResourceHandler::clear();
return 0;
}