diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-04-07 02:48:12 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-04-08 16:46:28 +0300 |
commit | 27a2dd4fce2d529cd1d96aa5ddce1e74b4f54a2f (patch) | |
tree | c2c38e1b4f308ca885dc3c3581560cfbc6833a8e /src/gui | |
parent | d4e28aa97cbce34a0053d3c02cf070ef9065439f (diff) | |
download | manaverse-27a2dd4fce2d529cd1d96aa5ddce1e74b4f54a2f.tar.gz manaverse-27a2dd4fce2d529cd1d96aa5ddce1e74b4f54a2f.tar.bz2 manaverse-27a2dd4fce2d529cd1d96aa5ddce1e74b4f54a2f.tar.xz manaverse-27a2dd4fce2d529cd1d96aa5ddce1e74b4f54a2f.zip |
Move resourcemanager from class to namespace.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/browserbox_unittest.cc | 19 | ||||
-rw-r--r-- | src/gui/widgets/desktop.cpp | 4 | ||||
-rw-r--r-- | src/gui/windowmanager_unittest.cc | 24 |
4 files changed, 42 insertions, 10 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 06afeccc6..227b0c463 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -300,7 +300,7 @@ Gui::~Gui() void Gui::logic() { BLOCK_START("Gui::logic") - resourceManager->clearScheduled(); + ResourceManager::clearScheduled(); if (!mTop) { @@ -359,8 +359,7 @@ void Gui::slowLogic() if (time > mTime10 || mTime10 - time > 10) { mTime10 = time + 10; - if (resourceManager) - resourceManager->cleanOrphans(); + ResourceManager::cleanOrphans(); } } diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index 6064dfd72..e86aa6b0e 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -47,11 +47,19 @@ extern const char *dirSeparator; +TEST_CASE("BrowserBox leak test1") +{ + logger = new Logger(); + REQUIRE(gui == nullptr); + ResourceManager::cleanOrphans(true); + ResourceManager::deleteInstance(); + delete2(logger); +} + TEST_CASE("BrowserBox tests", "browserbox") { client = new Client; logger = new Logger(); - ResourceManager::init(); VirtFs::mountDirSilent("data", Append_false); VirtFs::mountDirSilent("../data", Append_false); @@ -189,3 +197,12 @@ TEST_CASE("BrowserBox tests", "browserbox") delete2(logger); // VirtFs::deinit(); } + +TEST_CASE("BrowserBox leak test2") +{ + logger = new Logger(); + REQUIRE(gui == nullptr); + ResourceManager::cleanOrphans(true); + ResourceManager::deleteInstance(); + delete2(logger); +} diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 4aeea03b5..83d5bd58e 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -182,7 +182,7 @@ void Desktop::setBestFittingWallpaper() { if (mWallpaper) { - resourceManager->decRefDelete(mWallpaper); + ResourceManager::decRefDelete(mWallpaper); mWallpaper = nullptr; } @@ -200,7 +200,7 @@ void Desktop::setBestFittingWallpaper() if (newRsclWlPpr) { - resourceManager->decRefDelete(nWallPaper); + ResourceManager::decRefDelete(nWallPaper); // We replace the resource in the resource manager mWallpaper = newRsclWlPpr; } diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc index 49ea9d97c..b19844ac9 100644 --- a/src/gui/windowmanager_unittest.cc +++ b/src/gui/windowmanager_unittest.cc @@ -130,6 +130,15 @@ extern QuitDialog *quitDialog; +TEST_CASE("windows leak test1") +{ + logger = new Logger(); + REQUIRE(gui == nullptr); + ResourceManager::cleanOrphans(true); + ResourceManager::deleteInstance(); + delete2(logger); +} + TEST_CASE("Windows tests", "windowmanager") { setEnv("SDL_VIDEODRIVER", "dummy"); @@ -139,8 +148,7 @@ TEST_CASE("Windows tests", "windowmanager") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::deleteInstance(); - ResourceManager::init(); - resourceManager->cleanOrphans(true); + ResourceManager::cleanOrphans(true); VirtFs::mountDirSilent("data", Append_false); VirtFs::mountDirSilent("../data", Append_false); VirtFs::mountDirSilent("data/test", Append_false); @@ -723,8 +731,7 @@ TEST_CASE("WindowManager", "create windows") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::deleteInstance(); - ResourceManager::init(); - resourceManager->cleanOrphans(true); + ResourceManager::cleanOrphans(true); VirtFs::mountDirSilent("data", Append_false); VirtFs::mountDirSilent("../data", Append_false); VirtFs::mountDirSilent("data/test", Append_false); @@ -869,3 +876,12 @@ TEST_CASE("WindowManager", "create windows") // VirtFs::deinit(); } + +TEST_CASE("windows leak test2") +{ + logger = new Logger(); + REQUIRE(gui == nullptr); + ResourceManager::cleanOrphans(true); + ResourceManager::deleteInstance(); + delete2(logger); +} |