diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2010-06-01 13:32:03 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2010-06-01 13:36:29 (GMT) |
commit | 2c8f9dee611ed403ef129d5e3a3f9f5883bfd08b (patch) | |
tree | a3cdac743800005db95f644b4ea8577775c408ff /src/gui/image | |
parent | dab3121d59b202eac72a0b7d0fa101532ac080cd (diff) | |
download | Qt-2c8f9dee611ed403ef129d5e3a3f9f5883bfd08b.zip Qt-2c8f9dee611ed403ef129d5e3a3f9f5883bfd08b.tar.gz Qt-2c8f9dee611ed403ef129d5e3a3f9f5883bfd08b.tar.bz2 |
Some optimizations for QImage::load()
We didnt check if the file existed before trying to load it.
This means that we had a lot of redundant dlopen calls for
that case. In addition pixmap cache should be significantly
faster now.
Task-number: QTBUG-11137
Reviewed-by: joao
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 3013726..20e4b50 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -82,6 +82,7 @@ #endif #include "qpixmap_raster_p.h" +#include "private/qstylehelper_p.h" QT_BEGIN_NAMESPACE @@ -829,8 +830,14 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers return false; QFileInfo info(fileName); - QString key = QLatin1String("qt_pixmap_") + info.absoluteFilePath() + QLatin1Char('_') + QString::number(info.lastModified().toTime_t()) + QLatin1Char('_') + - QString::number(info.size()) + QLatin1Char('_') + QString::number(data ? data->pixelType() : QPixmapData::PixmapType); + if (!info.exists()) + return false; + + QString key = QLatin1Literal("qt_pixmap") + % info.absoluteFilePath() + % HexString<uint>(info.lastModified().toTime_t()) + % HexString<quint64>(info.size()) + % HexString<uint>(data ? data->pixelType() : QPixmapData::PixmapType); if (QPixmapCache::find(key, *this)) return true; |