From 061251bc26a6f4405df8c94af801a7c27590904b Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Thu, 28 Aug 2014 09:19:20 +0200 Subject: [PATCH] Get rid of QPixmap pointers According to my understanding of Qt documentation, there should be no need to manually create QPixmap with new and delete. This also makes things simpler for the model. --- src/libdanbooru/danboorupost.cpp | 10 ++++------ src/libdanbooru/danboorupost.h | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libdanbooru/danboorupost.cpp b/src/libdanbooru/danboorupost.cpp index c049572..37da56b 100644 --- a/src/libdanbooru/danboorupost.cpp +++ b/src/libdanbooru/danboorupost.cpp @@ -38,7 +38,7 @@ namespace Danbooru { const QMap DanbooruPost::RATING_MAP = initRatingMap(); - DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap* pixmap, + DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap, QObject* parent): QObject(parent), m_pixmap(pixmap) @@ -56,9 +56,7 @@ namespace Danbooru { } - DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, - QPixmap* pixmap, - QObject* parent): + DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObject* parent): QObject(parent), m_pixmap(pixmap) { @@ -101,7 +99,7 @@ namespace Danbooru { } - void DanbooruPost::setPixmap(const QPixmap* pixmap) + void DanbooruPost::setPixmap(const QPixmap pixmap) { m_pixmap = pixmap; } @@ -138,7 +136,7 @@ namespace Danbooru { return m_thumbnailUrl; } - const QPixmap* DanbooruPost::pixmap() const + const QPixmap DanbooruPost::pixmap() const { return m_pixmap; } diff --git a/src/libdanbooru/danboorupost.h b/src/libdanbooru/danboorupost.h index 16afa08..c583720 100644 --- a/src/libdanbooru/danboorupost.h +++ b/src/libdanbooru/danboorupost.h @@ -30,11 +30,12 @@ // Qt -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include // KDE @@ -70,7 +71,7 @@ namespace Danbooru { Q_OBJECT - Q_PROPERTY(const QPixmap* pixmap READ pixmap WRITE setPixmap) + Q_PROPERTY(const QPixmap pixmap READ pixmap WRITE setPixmap) Q_PROPERTY(int id READ id) Q_PROPERTY(KUrl fileUrl READ fileUrl) Q_PROPERTY(QSet tags READ tags) @@ -78,7 +79,7 @@ namespace Danbooru { private: - const QPixmap* m_pixmap; + const QPixmap m_pixmap; // basic features of a post @@ -113,7 +114,7 @@ namespace Danbooru { * @param parent A pointer to the parent QObject. * **/ - explicit DanbooruPost(QVariantMap postData, QPixmap* pixmap = 0, + explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(), QObject* parent = 0); /** @@ -131,7 +132,7 @@ namespace Danbooru { * **/ explicit DanbooruPost(QXmlStreamAttributes& postData, - QPixmap* pixmap = 0, QObject* parent=0); + QPixmap pixmap = QPixmap(), QObject* parent =0); bool operator==(const DanbooruPost&); @@ -177,7 +178,7 @@ namespace Danbooru { /** * @return A pointer to the thumbnail's pixmap. **/ - const QPixmap* pixmap() const; + const QPixmap pixmap() const; /** * @return The current post's rating. @@ -188,7 +189,7 @@ namespace Danbooru { * Set the post's pixmap to a specific QPixmap instance's pointer. * **/ - void setPixmap(const QPixmap* pixmap); + void setPixmap(const QPixmap pixmap); /** * @return A string representation of the post. @@ -203,3 +204,4 @@ namespace Danbooru { Q_DECLARE_METATYPE(Danbooru::DanbooruPost*) #endif // DANBOORUPOST_H +