summaryrefslogtreecommitdiffstats
path: root/src/widget/wdisplay.cpp
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2013-12-24 02:42:05 -0500
committerRJ Ryan <rryan@mixxx.org>2013-12-24 02:42:05 -0500
commit31910722ffab602bfed98333cd31a10fc0163475 (patch)
tree2294bfb3a12796056a546a2472726652d222a9f3 /src/widget/wdisplay.cpp
parent8e069765f06b9d8fdc9a05d9b2c87fbbce8bdf3d (diff)
Get rid of manual reference counting in WPixmapStore and just use QSharedPointer.
Diffstat (limited to 'src/widget/wdisplay.cpp')
-rw-r--r--src/widget/wdisplay.cpp35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/widget/wdisplay.cpp b/src/widget/wdisplay.cpp
index 471df62ea2..ec8906fa44 100644
--- a/src/widget/wdisplay.cpp
+++ b/src/widget/wdisplay.cpp
@@ -76,49 +76,28 @@ void WDisplay::setPositions(int iNoPos) {
}
void WDisplay::resetPositions() {
- for (int i = 0; i < m_pixmaps.size(); ++i) {
- QPixmap* pPixmap = m_pixmaps[i];
- if (pPixmap) {
- WPixmapStore::deletePixmap(pPixmap);
- }
- }
- for (int i = 0; i < m_disabledPixmaps.size(); ++i) {
- QPixmap* pPixmap = m_disabledPixmaps[i];
- if (pPixmap) {
- WPixmapStore::deletePixmap(pPixmap);
- }
- }
- if (m_pPixmapBack) {
- WPixmapStore::deletePixmap(m_pPixmapBack);
- m_pPixmapBack = NULL;
- }
+ m_pPixmapBack.clear();
m_pixmaps.resize(0);
m_disabledPixmaps.resize(0);
}
void WDisplay::setPixmapBackground(const QString& filename) {
- // Free the pixmap if it is already allocated.
- if (m_pPixmapBack) {
- WPixmapStore::deletePixmap(m_pPixmapBack);
- m_pPixmapBack = NULL;
- }
-
m_pPixmapBack = WPixmapStore::getPixmap(filename);
- if (m_pPixmapBack == NULL || m_pPixmapBack->isNull()) {
+ if (m_pPixmapBack.isNull() || m_pPixmapBack->isNull()) {
qDebug() << metaObject()->className()
<< "Error loading background pixmap:" << filename;
}
}
-void WDisplay::setPixmap(QVector<QPixmap*>* pPixmaps, int iPos,
+void WDisplay::setPixmap(QVector<QPixmapPointer>* pPixmaps, int iPos,
const QString& filename) {
if (iPos < 0 || iPos >= pPixmaps->size()) {
return;
}
- QPixmap* pPixmap = WPixmapStore::getPixmap(filename);
+ QPixmapPointer pPixmap = WPixmapStore::getPixmap(filename);
- if (pPixmap == NULL || pPixmap->isNull()) {
+ if (pPixmap.isNull() || pPixmap->isNull()) {
qDebug() << metaObject()->className()
<< "Error loading pixmap:" << filename;
} else {
@@ -141,7 +120,7 @@ void WDisplay::paintEvent(QPaintEvent* ) {
// If we are disabled, use the disabled pixmaps. If not, use the regular
// pixmaps.
- const QVector<QPixmap*>& pixmaps = (m_bOff && m_bDisabledLoaded) ?
+ const QVector<QPixmapPointer>& pixmaps = (m_bOff && m_bDisabledLoaded) ?
m_disabledPixmaps : m_pixmaps;
if (pixmaps.empty()) {
@@ -157,7 +136,7 @@ void WDisplay::paintEvent(QPaintEvent* ) {
idx = pixmaps.size() - 1;
}
- QPixmap* pPixmap = pixmaps[idx];
+ QPixmapPointer pPixmap = pixmaps[idx];
if (pPixmap) {
p.drawPixmap(0, 0, *pPixmap);
}