diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-12-21 00:11:54 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-12-21 00:11:54 (GMT) |
commit | 944f41b814d826191a713de34cb9fdda439d14c5 (patch) | |
tree | 8735c6d3b31ce780c7ec055d4013de15254e570a /src/declarative/util/qmlpixmapcache.cpp | |
parent | d49648884774f320473427fcea52a51ac2a4cca5 (diff) | |
download | Qt-944f41b814d826191a713de34cb9fdda439d14c5.zip Qt-944f41b814d826191a713de34cb9fdda439d14c5.tar.gz Qt-944f41b814d826191a713de34cb9fdda439d14c5.tar.bz2 |
Remove unnecessary locking.
Diffstat (limited to 'src/declarative/util/qmlpixmapcache.cpp')
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 99bcb7b..475a21e 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -84,7 +84,6 @@ private: void loadImage(Job &job); QList<Job> jobs; - Job runningJob; QMutex mutex; QWaitCondition haveJob; bool quit; @@ -119,22 +118,21 @@ void QmlImageReader::read(QmlPixmapReply *reply) Job job; job.reply = reply; jobs.append(job); - haveJob.wakeOne(); + if (jobs.count() == 1) + haveJob.wakeOne(); mutex.unlock(); } void QmlImageReader::cancel(QmlPixmapReply *reply) { mutex.lock(); - if (runningJob.reply != reply) { - QList<Job>::iterator it = jobs.begin(); - while (it != jobs.end()) { - if ((*it).reply == reply) { - jobs.erase(it); - break; - } - ++it; + QList<Job>::iterator it = jobs.begin(); + while (it != jobs.end()) { + if ((*it).reply == reply) { + jobs.erase(it); + break; } + ++it; } mutex.unlock(); } @@ -158,14 +156,12 @@ void QmlImageReader::run() haveJob.wait(&mutex); if (quit) break; - runningJob = jobs.takeFirst(); + Job runningJob = jobs.takeFirst(); runningJob.reply->addRef(); mutex.unlock(); + loadImage(runningJob); - mutex.lock(); QCoreApplication::postEvent(runningJob.reply, new QmlImageDecodeEvent(runningJob.error, runningJob.img)); - runningJob.reply = 0; - mutex.unlock(); } } |