summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-02 21:17:53 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-02 21:17:53 +0300
commitbfa44d6b007ca2e3ffabafda5beadbf102a6efdc (patch)
tree8f5d51f3ac6486f42aa531032209a0dddcc6e45d
parent181ecd0c3bf27b47487f973fb83b988fd6ceaecf (diff)
downloadplus-bfa44d6b007ca2e3ffabafda5beadbf102a6efdc.tar.gz
plus-bfa44d6b007ca2e3ffabafda5beadbf102a6efdc.tar.bz2
plus-bfa44d6b007ca2e3ffabafda5beadbf102a6efdc.tar.xz
plus-bfa44d6b007ca2e3ffabafda5beadbf102a6efdc.zip
Other fixes from Coverity checks.
-rw-r--r--src/resources/atlasmanager.cpp11
-rw-r--r--src/resources/image.cpp2
-rw-r--r--src/resources/mapreader.cpp12
-rw-r--r--src/resources/resource.h3
-rw-r--r--src/resources/resourcemanager.cpp11
5 files changed, 22 insertions, 17 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index 9ff01b9c4..0d43d59c8 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -256,14 +256,15 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *atlas)
void AtlasManager::convertAtlas(TextureAtlas *atlas)
{
+ // no check for null pointer in atlas because it was in caller
// convert surface to OpemGL image
atlas->atlasImage = imageHelper->load(atlas->surface);
Image *const image = atlas->atlasImage;
- if (image)
- {
- image->mIdPath = atlas->name;
- image->incRef();
- }
+ if (!image)
+ return;
+
+ image->mIdPath = atlas->name;
+ image->incRef();
FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
{
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 9524a64bd..407274459 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -49,6 +49,8 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
Resource(),
#ifdef USE_OPENGL
mGLImage(0),
+ mTexWidth(0),
+ mTexHeight(0),
#endif
mLoaded(false),
mAlpha(1.0f),
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index ec7651745..98de2cd49 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -242,10 +242,11 @@ Map *MapReader::readMap(const std::string &filename,
{
map->setProperty("_filename", realFilename);
map->setProperty("_realfilename", filename);
+
+ if (map->getProperty("music").empty())
+ updateMusic(map);
}
- if (map->getProperty("music").empty())
- updateMusic(map);
return map;
}
@@ -716,7 +717,10 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
doc = new XML::Document(filename);
node = doc->rootNode();
if (!node)
+ {
+ delete doc;
return nullptr;
+ }
// Reset path to be realtive to the tsx file
pathDir = filename.substr(0, filename.rfind("/") + 1);
@@ -729,6 +733,10 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
{
if (xmlNameEqual(childNode, "image"))
{
+ // ignore second other <image> tags in tileset
+ if (set)
+ continue;
+
const std::string source = XML::getProperty(
childNode, "source", "");
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 8cd8dabd6..fd0a34fb0 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -42,8 +42,9 @@ class Resource
* Constructor
*/
Resource() :
-#ifdef DEBUG_DUMP_LEAKS
+ mTimeStamp(0),
mRefCount(0),
+#ifdef DEBUG_DUMP_LEAKS
mDumped(false)
#else
mRefCount(0)
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 7759fdb73..e8e9f14c1 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -238,15 +238,8 @@ void ResourceManager::logResource(const Resource *const res)
const int count = image->getRefCount();
if (count)
src.append(" ").append(toString(count));
- if (image)
- {
- logger->log("resource(%s, %u) %s", res->mIdPath.c_str(),
- image->getGLImage(), src.c_str());
- }
- else
- {
- logger->log("resource(%s) %s", res->mIdPath.c_str(), src.c_str());
- }
+ logger->log("resource(%s, %u) %s", res->mIdPath.c_str(),
+ image->getGLImage(), src.c_str());
}
else
{