diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-30 15:47:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-30 19:38:07 +0300 |
commit | 8b984259c0d7d7af5394defc89a3b64d7b479425 (patch) | |
tree | f67aef7fc0ffb2fb0d54dc042b49bb33805a4a0e /src/resources/atlasmanager.cpp | |
parent | 2c9fbdd6e9579549735eeb4cdfd83eef7e4ec55e (diff) | |
download | mv-8b984259c0d7d7af5394defc89a3b64d7b479425.tar.gz mv-8b984259c0d7d7af5394defc89a3b64d7b479425.tar.bz2 mv-8b984259c0d7d7af5394defc89a3b64d7b479425.tar.xz mv-8b984259c0d7d7af5394defc89a3b64d7b479425.zip |
Some fixes in atlases deletion.
Diffstat (limited to 'src/resources/atlasmanager.cpp')
-rw-r--r-- | src/resources/atlasmanager.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index a9745bd08..5a43454b4 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -92,16 +92,21 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, void AtlasManager::loadImages(const StringVect &files, std::vector<Image*> &images) { - const ResourceManager *const resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); for (StringVectCIter it = files.begin(), it_end = files.end(); it != it_end; ++ it) { const std::string str = *it; - if (resman->isInCache(str)) + // check is image with same name already in cache + // and if yes, move it to deleted set + Resource *const res = resman->getTempResource(str); + if (res) { - logger->log("Resource %s already in cache", str.c_str()); - continue; + //logger->log("Resource %s already in cache", str.c_str()); + // increase counter because in moveToDeleted it will be decreased. + res->incRef(); + resman->moveToDeleted(res); } SDL_RWops *rw = PHYSFSRWOPS_openRead(str.c_str()); @@ -292,7 +297,7 @@ void AtlasManager::moveToDeleted(AtlasResource *resource) Image *const image = atlas->atlasImage; if (image) { - image->decRef(); + // move each atlas image to deleted resman->moveToDeleted(image); } for (std::vector<AtlasItem*>::iterator it2 = atlas->items.begin(), @@ -305,7 +310,6 @@ void AtlasManager::moveToDeleted(AtlasResource *resource) Image *const image2 = item->image; if (image2) { - image2->decRef(); // move each atlas sub image to deleted resman->moveToDeleted(image2); } @@ -329,16 +333,8 @@ AtlasResource::~AtlasResource() { AtlasItem *const item = *it2; if (item) - { -// Image *const image = item->image; -// if (image) -// image->decRef(); delete item; - } } -// Image *const image = atlas->atlasImage; -// if (image) -// image->decRef(); delete atlas; } } |