summaryrefslogtreecommitdiff
path: root/src/resources/iteminfo.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 15:00:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 15:00:47 +0000
commit77efbb50066a030d1f44f8de8d06ace9f284e3a2 (patch)
tree22d737ac0058e4fa87e7767d41e02999bcbf84be /src/resources/iteminfo.cpp
parent40ca3dc75197412594c5f6a78d68b265e235024b (diff)
downloadmana-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.gz
mana-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.bz2
mana-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.xz
mana-77efbb50066a030d1f44f8de8d06ace9f284e3a2.zip
Introduced SelectionListener to fix updating problem in inventory window
(should also be used to fix similar problem in trade, buy and sell dialogs). Made the ItemInfo be passed around as a reference instead of a pointer, since it is never NULL.
Diffstat (limited to 'src/resources/iteminfo.cpp')
-rw-r--r--src/resources/iteminfo.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 5d39d832..b09d1cc0 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -23,22 +23,33 @@
#include "iteminfo.h"
#include "resourcemanager.h"
+#include "image.h"
-Image*
-ItemInfo::getImage() {
- if (mImage == NULL && mImageName != "") {
- mImage = ResourceManager::getInstance()->getImage(mImageName);
+
+ItemInfo::~ItemInfo()
+{
+ if (mImage != NULL)
+ {
+ mImage->decRef();
}
- return mImage;
}
void
-ItemInfo::setImage(const std::string &image) {
+ItemInfo::setImage(const std::string &image)
+{
mImageName = "graphics/items/" + image;
-}
-ItemInfo::~ItemInfo() {
- if (mImage != NULL){
- mImage->decRef();
+ if (mImageName != "")
+ {
+ if (mImage != NULL)
+ {
+ mImage->decRef();
+ }
+
+ mImage = ResourceManager::getInstance()->getImage(mImageName);
+ }
+ else
+ {
+ mImage = NULL;
}
}