summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-14 22:11:56 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-14 22:11:56 +0300
commitd0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21 (patch)
tree169feb38c052933325683490b9174aff48a2a438
parenta2c06346e1830d888a72ccdb2e224686319af014 (diff)
downloadplus-d0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21.tar.gz
plus-d0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21.tar.bz2
plus-d0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21.tar.xz
plus-d0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21.zip
add flag into resource and imageset what prevent subimage or other resource from auto removing.
-rw-r--r--src/resources/imageset.cpp4
-rw-r--r--src/resources/resource.cpp2
-rw-r--r--src/resources/resource.h9
3 files changed, 11 insertions, 4 deletions
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 164e682a4..5f62af574 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -49,7 +49,9 @@ ImageSet::ImageSet(Image *const img, const int width, const int height,
for (int x = margin; x + width <= img->getWidth() - margin;
x += wAdd)
{
- mImages.push_back(img->getSubImage(x, y, width, height));
+ Image *const image = img->getSubImage(x, y, width, height);
+ image->setNotCount(true);
+ mImages.push_back(image);
}
}
}
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index b111a4081..b67fe644b 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -49,7 +49,7 @@ void Resource::decRef()
mRefCount--;
- if (mRefCount == 0)
+ if (mRefCount == 0 && !mNotCount)
{
// Warn the manager that this resource is no longer used.
ResourceManager *const resman = ResourceManager::getInstance();
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 0aa2e34b0..a60d6765c 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -46,11 +46,12 @@ class Resource
mSource(),
mTimeStamp(0),
mRefCount(0),
-#ifdef DEBUG_DUMP_LEAKS
mProtected(false),
+#ifdef DEBUG_DUMP_LEAKS
+ mNotCount(false),
mDumped(false)
#else
- mProtected(false)
+ mNotCount(false)
#endif
{
}
@@ -95,6 +96,9 @@ class Resource
bool isProtected() const
{ return mProtected; }
+ void setNotCount(bool b)
+ { mNotCount = b; }
+
#ifdef DEBUG_DUMP_LEAKS
bool getDumped() const A_WARN_UNUSED
{ return mDumped; }
@@ -116,6 +120,7 @@ class Resource
time_t mTimeStamp; /**< Time at which the resource was orphaned. */
unsigned int mRefCount; /**< Reference count. */
bool mProtected;
+ bool mNotCount;
#ifdef DEBUG_DUMP_LEAKS
bool mDumped;
#endif