[Scummvm-cvs-logs] scummvm master -> fe7332cb181368ab18fd05125bf64f50fa912919
sev-
sev at scummvm.org
Sun Mar 6 01:37:05 CET 2016
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9515d07f00 SWORD25: Fixed "Resource not released" warnings [GSoC]
fe7332cb18 Merge pull request #689 from Tkachov/master
Commit: 9515d07f003854ee4816a56b9b2a709aafc8fdf0
https://github.com/scummvm/scummvm/commit/9515d07f003854ee4816a56b9b2a709aafc8fdf0
Author: Tkachov (Tkachov at TLab)
Date: 2016-03-04T22:21:11+06:00
Commit Message:
SWORD25: Fixed "Resource not released" warnings [GSoC]
(Look https://sourceforge.net/p/scummvm/bugs/6980/)
The warning messages were appearing because when PRECACHE_RESOURCES is
not defined, ResourceManager's `requestResource()` was used to manually
"cache" them. When you do that, ResourceManager "locks" the resource
once, so you must `release()` it later.
Resources were not released, and warnings appeared. When you
`release()` resource, it still is loaded ("cached"). Resource's
`getLockCount()` is 0, though, so it might be unloaded by
ResourceManager if there is a lot of resources.
Changed paths:
engines/sword25/gfx/animationresource.cpp
engines/sword25/gfx/fontresource.cpp
engines/sword25/gfx/text.cpp
diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp
index 431d466..423a2b8 100644
--- a/engines/sword25/gfx/animationresource.cpp
+++ b/engines/sword25/gfx/animationresource.cpp
@@ -211,8 +211,9 @@ bool AnimationResource::precacheAllFrames() const {
error("Could not precache \"%s\".", (*iter).fileName.c_str());
return false;
}
-#else
- Kernel::getInstance()->getResourceManager()->requestResource((*iter).fileName);
+#else
+ Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource((*iter).fileName);
+ pResource->release(); //unlock precached resource
#endif
}
diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp
index c4d4c3c..1d7aedc 100644
--- a/engines/sword25/gfx/fontresource.cpp
+++ b/engines/sword25/gfx/fontresource.cpp
@@ -103,8 +103,9 @@ bool FontResource::parserCallback_font(ParserNode *node) {
if (!_pKernel->getResourceManager()->precacheResource(_bitmapFileName)) {
error("Could not precache \"%s\".", _bitmapFileName.c_str());
}
-#else
- _pKernel->getResourceManager()->requestResource(_bitmapFileName);
+#else
+ Resource *pResource = _pKernel->getResourceManager()->requestResource(_bitmapFileName);
+ pResource->release(); //unlock precached resource
#endif
return true;
diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp
index d409c53..769c9b1 100644
--- a/engines/sword25/gfx/text.cpp
+++ b/engines/sword25/gfx/text.cpp
@@ -77,7 +77,8 @@ bool Text::setFont(const Common::String &font) {
return false;
}
#else
- getResourceManager()->requestResource(font);
+ Resource *pResource = getResourceManager()->requestResource(font);
+ pResource->release(); //unlock precached resource
_font = font;
updateFormat();
forceRefresh();
Commit: fe7332cb181368ab18fd05125bf64f50fa912919
https://github.com/scummvm/scummvm/commit/fe7332cb181368ab18fd05125bf64f50fa912919
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-03-06T01:37:03+01:00
Commit Message:
Merge pull request #689 from Tkachov/master
SWORD25: Fix "Resource not released" warnings
Changed paths:
engines/sword25/gfx/animationresource.cpp
engines/sword25/gfx/fontresource.cpp
engines/sword25/gfx/text.cpp
More information about the Scummvm-git-logs
mailing list