summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2009-08-26 09:47:53 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2009-08-26 09:52:58 (GMT)
commit3d33fb250c4d23b746124b8d1f1a974cdacb48e6 (patch)
tree26074e31da1df6f0a63b24cdf0959e0ed648ea99
parent5d29928f2988c474a9b7e8554860851bef15b989 (diff)
downloadQt-3d33fb250c4d23b746124b8d1f1a974cdacb48e6.zip
Qt-3d33fb250c4d23b746124b8d1f1a974cdacb48e6.tar.gz
Qt-3d33fb250c4d23b746124b8d1f1a974cdacb48e6.tar.bz2
Fix unbalanced calls to QFxPixmapCache::get && cancelGet
Explicitly track whether there is a QFxPixmapCache request pending, and only call QFxPixmapCache::cancelGet if this is the case. This should fix an issue in Bauhaus where multiple instances are loading the same image, and one instance calling cancelGet without ever having called get before is messing up the QFxPixmapCache request counting.
-rw-r--r--src/declarative/extra/qfxparticles.cpp16
-rw-r--r--src/declarative/fx/qfxborderimage.cpp15
-rw-r--r--src/declarative/fx/qfxborderimage_p.h2
-rw-r--r--src/declarative/fx/qfximagebase.cpp10
-rw-r--r--src/declarative/fx/qfximagebase_p.h4
5 files changed, 36 insertions, 11 deletions
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp
index ec15099..7855f3e 100644
--- a/src/declarative/extra/qfxparticles.cpp
+++ b/src/declarative/extra/qfxparticles.cpp
@@ -368,7 +368,7 @@ public:
: count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
, angle(0), angleDev(0), velocity(0), velocityDev(0)
, addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0)
- , emitting(true), motion(0), clock(this)
+ , emitting(true), motion(0), pendingPixmapCache(false), clock(this)
{
}
@@ -406,6 +406,8 @@ public:
QFxParticleMotion *motion;
QFxParticlesPainter *paintItem;
+ bool pendingPixmapCache;
+
QList<QFxParticle> particles;
QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock;
@@ -615,7 +617,7 @@ QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent)
QFxParticles::~QFxParticles()
{
Q_D(QFxParticles);
- if (!d->url.isEmpty())
+ if (d->pendingPixmapCache)
QFxPixmapCache::cancelGet(d->url, this);
}
@@ -637,6 +639,7 @@ QUrl QFxParticles::source() const
void QFxParticles::imageLoaded()
{
Q_D(QFxParticles);
+ d->pendingPixmapCache = false;
QFxPixmapCache::find(d->url, &d->image);
d->paintItem->updateSize();
d->paintItem->update();
@@ -649,8 +652,10 @@ void QFxParticles::setSource(const QUrl &name)
if ((d->url.isEmpty() == name.isEmpty()) && name == d->url)
return;
- if (!d->url.isEmpty())
+ if (d->pendingPixmapCache) {
QFxPixmapCache::cancelGet(d->url, this);
+ d->pendingPixmapCache = false;
+ }
if (name.isEmpty()) {
d->url = name;
d->image = QPixmap();
@@ -660,9 +665,10 @@ void QFxParticles::setSource(const QUrl &name)
d->url = name;
Q_ASSERT(!name.isRelative());
QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->image);
- if (reply)
+ if (reply) {
connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
- else {
+ d->pendingPixmapCache = true;
+ } else {
//### unify with imageLoaded
d->paintItem->updateSize();
d->paintItem->update();
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp
index 60faa84..d199d5d 100644
--- a/src/declarative/fx/qfxborderimage.cpp
+++ b/src/declarative/fx/qfxborderimage.cpp
@@ -79,7 +79,7 @@ QFxBorderImage::~QFxBorderImage()
Q_D(QFxBorderImage);
if (d->sciReply)
d->sciReply->deleteLater();
- if (!d->sciurl.isEmpty())
+ if (d->sciPendingPixmapCache)
QFxPixmapCache::cancelGet(d->sciurl, this);
}
/*!
@@ -153,10 +153,14 @@ void QFxBorderImage::setSource(const QUrl &url)
d->sciReply = 0;
}
- if (!d->url.isEmpty())
+ if (d->pendingPixmapCache) {
QFxPixmapCache::cancelGet(d->url, this);
- if (!d->sciurl.isEmpty())
+ d->pendingPixmapCache = false;
+ }
+ if (d->sciPendingPixmapCache) {
QFxPixmapCache::cancelGet(d->sciurl, this);
+ d->sciPendingPixmapCache = false;
+ }
d->url = url;
d->sciurl = QUrl();
@@ -194,6 +198,7 @@ void QFxBorderImage::setSource(const QUrl &url)
} else {
QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix);
if (reply) {
+ d->pendingPixmapCache = true;
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(requestProgress(qint64,qint64)));
@@ -310,6 +315,7 @@ void QFxBorderImage::setGridScaledImage(const QFxGridScaledImage& sci)
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix);
if (reply) {
+ d->sciPendingPixmapCache = true;
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(requestProgress(qint64,qint64)));
@@ -332,9 +338,12 @@ void QFxBorderImage::setGridScaledImage(const QFxGridScaledImage& sci)
void QFxBorderImage::requestFinished()
{
Q_D(QFxBorderImage);
+
if (d->url.path().endsWith(QLatin1String(".sci"))) {
+ d->sciPendingPixmapCache = false;
QFxPixmapCache::find(d->sciurl, &d->pix);
} else {
+ d->pendingPixmapCache = false;
if (!QFxPixmapCache::find(d->url, &d->pix))
d->status = Error;
}
diff --git a/src/declarative/fx/qfxborderimage_p.h b/src/declarative/fx/qfxborderimage_p.h
index 809b00d..aebe13f 100644
--- a/src/declarative/fx/qfxborderimage_p.h
+++ b/src/declarative/fx/qfxborderimage_p.h
@@ -66,6 +66,7 @@ class QFxBorderImagePrivate : public QFxImageBasePrivate
public:
QFxBorderImagePrivate()
: border(0), sciReply(0),
+ sciPendingPixmapCache(false),
horizontalTileMode(QFxBorderImage::Stretch),
verticalTileMode(QFxBorderImage::Stretch)
{
@@ -86,6 +87,7 @@ public:
QFxScaleGrid *border;
QUrl sciurl;
QNetworkReply *sciReply;
+ bool sciPendingPixmapCache;
QFxBorderImage::TileMode horizontalTileMode;
QFxBorderImage::TileMode verticalTileMode;
};
diff --git a/src/declarative/fx/qfximagebase.cpp b/src/declarative/fx/qfximagebase.cpp
index 5aa87db..a68c1f9 100644
--- a/src/declarative/fx/qfximagebase.cpp
+++ b/src/declarative/fx/qfximagebase.cpp
@@ -64,7 +64,7 @@ QFxImageBase::QFxImageBase(QFxImageBasePrivate &dd, QFxItem *parent)
QFxImageBase::~QFxImageBase()
{
Q_D(QFxImageBase);
- if (!d->url.isEmpty())
+ if (d->pendingPixmapCache)
QFxPixmapCache::cancelGet(d->url, this);
}
@@ -94,8 +94,10 @@ void QFxImageBase::setSource(const QUrl &url)
if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
return;
- if (!d->url.isEmpty())
+ if (d->pendingPixmapCache) {
QFxPixmapCache::cancelGet(d->url, this);
+ d->pendingPixmapCache = false;
+ }
d->url = url;
if (d->progress != 0.0) {
@@ -117,6 +119,7 @@ void QFxImageBase::setSource(const QUrl &url)
d->status = Loading;
QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix);
if (reply) {
+ d->pendingPixmapCache = true;
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(requestProgress(qint64,qint64)));
@@ -141,6 +144,9 @@ void QFxImageBase::setSource(const QUrl &url)
void QFxImageBase::requestFinished()
{
Q_D(QFxImageBase);
+
+ d->pendingPixmapCache = false;
+
if (!QFxPixmapCache::find(d->url, &d->pix))
d->status = Error;
setImplicitWidth(d->pix.width());
diff --git a/src/declarative/fx/qfximagebase_p.h b/src/declarative/fx/qfximagebase_p.h
index 3f43f38..a6fcc80 100644
--- a/src/declarative/fx/qfximagebase_p.h
+++ b/src/declarative/fx/qfximagebase_p.h
@@ -66,7 +66,8 @@ class QFxImageBasePrivate : public QFxItemPrivate
public:
QFxImageBasePrivate()
: status(QFxImageBase::Null),
- progress(0.0)
+ progress(0.0),
+ pendingPixmapCache(false)
{
}
@@ -74,6 +75,7 @@ public:
QFxImageBase::Status status;
QUrl url;
qreal progress;
+ bool pendingPixmapCache;
};
QT_END_NAMESPACE