diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-27 19:43:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-27 19:43:36 +0300 |
commit | 5b72d1606316a05fb0121b4244583b3435ea0db8 (patch) | |
tree | 14ccdadbd5319d27335657fae7ca348ab1ad268f | |
parent | 5c0b932b4c3dcd339d0ef123c24fb7de427162d5 (diff) | |
download | manaverse-5b72d1606316a05fb0121b4244583b3435ea0db8.tar.gz manaverse-5b72d1606316a05fb0121b4244583b3435ea0db8.tar.bz2 manaverse-5b72d1606316a05fb0121b4244583b3435ea0db8.tar.xz manaverse-5b72d1606316a05fb0121b4244583b3435ea0db8.zip |
Call cleanOrphans after disconnecting from server.
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 4 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 3 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp index 29c464180..d512ac6e4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -793,6 +793,9 @@ int Client::exec() { delete game; game = 0; + ResourceManager *resman = ResourceManager::getInstance(); + if (resman) + resman->cleanOrphans(); } mOldState = mState; diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index c0fe01ca8..a86edbb6f 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -171,14 +171,14 @@ void ResourceManager::cleanUp(Resource *res) delete res; } -void ResourceManager::cleanOrphans() +void ResourceManager::cleanOrphans(bool always) { timeval tv; gettimeofday(&tv, NULL); // Delete orphaned resources after 30 seconds. time_t oldest = tv.tv_sec, threshold = oldest - 30; - if (mOrphanedResources.empty() || mOldestOrphan >= threshold) + if (mOrphanedResources.empty() || (!always && mOldestOrphan >= threshold)) return; ResourceIterator iter = mOrphanedResources.begin(); diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 8d1070463..71cbdce62 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -248,13 +248,14 @@ class ResourceManager { return &mOrphanedResources; } #endif + void cleanOrphans(bool always = false); + private: /** * Deletes the resource after logging a cleanup message. */ static void cleanUp(Resource *resource); - void cleanOrphans(); static ResourceManager *instance; std::set<SDL_Surface*> deletedSurfaces; |