From 944f41b814d826191a713de34cb9fdda439d14c5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 21 Dec 2009 10:11:54 +1000 Subject: Remove unnecessary locking. --- src/declarative/util/qmlpixmapcache.cpp | 24 ++++++++++-------------- 1 file 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 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::iterator it = jobs.begin(); - while (it != jobs.end()) { - if ((*it).reply == reply) { - jobs.erase(it); - break; - } - ++it; + QList::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(); } } -- cgit v0.12