summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/desktop.cpp13
-rw-r--r--src/gui/widgets/desktop.h4
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/icon.cpp7
-rw-r--r--src/gui/widgets/icon.h10
5 files changed, 19 insertions, 17 deletions
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 474aadb0..ca86360e 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -52,11 +52,7 @@ Desktop::Desktop()
add(mVersionLabel, 25, 2);
}
-Desktop::~Desktop()
-{
- if (mWallpaper)
- mWallpaper->decRef();
-}
+Desktop::~Desktop() = default;
void Desktop::reloadWallpaper()
{
@@ -109,14 +105,11 @@ void Desktop::setBestFittingWallpaper()
return;
ResourceManager *resman = ResourceManager::getInstance();
- Image *wallpaper = resman->getImage(wallpaperName);
+ auto wallpaper = resman->getImageRef(wallpaperName);
if (wallpaper)
{
- if (mWallpaper)
- mWallpaper->decRef(Resource::DeleteImmediately);
-
- mWallpaper = wallpaper;
+ mWallpaper = std::move(wallpaper);
}
else
{
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 97294423..5909ac72 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -26,6 +26,8 @@
#include "gui/widgets/container.h"
+#include "resources/resource.h"
+
#include <guichan/widgetlistener.hpp>
class Image;
@@ -61,7 +63,7 @@ class Desktop : public Container, gcn::WidgetListener
private:
void setBestFittingWallpaper();
- Image *mWallpaper = nullptr;
+ ResourceRef<Image> mWallpaper;
gcn::Label *mVersionLabel;
};
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 4df0c4b9..c72d166f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -89,7 +89,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
if (mEmoteMoved != -1)
{
// Draw the emote image being dragged by the cursor.
- const ImageSprite *sprite = EmoteDB::get(mEmoteMoved).sprite;
+ const ImageSprite *sprite = EmoteDB::get(mEmoteMoved).sprite.get();
const int tPosX = mCursorPosX - (sprite->getWidth() / 2);
const int tPosY = mCursorPosY - (sprite->getHeight() / 2);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 5becadd1..67fd8384 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -27,14 +27,17 @@
#include "resources/resourcemanager.h"
Icon::Icon(const std::string &file)
- : Icon(ResourceManager::getInstance()->getImage(file))
-{}
+ : Icon(ResourceManager::getInstance()->getImageRef(file))
+{
+}
Icon::Icon(Image *image)
{
setImage(image);
}
+Icon::~Icon() = default;
+
void Icon::setImage(Image *image)
{
mImage = image;
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
index 508d2095..3ebc2c16 100644
--- a/src/gui/widgets/icon.h
+++ b/src/gui/widgets/icon.h
@@ -22,6 +22,8 @@
#ifndef ICON_H
#define ICON_H
+#include "resources/resource.h"
+
#include <guichan/widget.hpp>
class Image;
@@ -39,12 +41,14 @@ class Icon : public gcn::Widget
*
* @param filename The file name of the image to display
*/
- Icon(const std::string &filename);
+ explicit Icon(const std::string &filename);
/**
* Constructor, uses an existing Image.
*/
- Icon(Image *image);
+ explicit Icon(Image *image = nullptr);
+
+ ~Icon() override;
/**
* Gets the current Image.
@@ -62,7 +66,7 @@ class Icon : public gcn::Widget
void draw(gcn::Graphics *g) override;
private:
- Image *mImage = nullptr;
+ ResourceRef<Image> mImage;
};
#endif // ICON_H