diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-15 15:54:27 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-15 15:54:27 (GMT) |
commit | 88fa17f5664e3839ffc04db1315e8d9d07f8b956 (patch) | |
tree | 65c63c815a169ffcb02fa3a3bdb63d2e2d9ba4cb /src/gui/image | |
parent | 8d7046fbd798c6104eca6098b828c505ca32085c (diff) | |
parent | 925c41f2a1c38d958de3844785bcc8c83ff74004 (diff) | |
download | Qt-88fa17f5664e3839ffc04db1315e8d9d07f8b956.zip Qt-88fa17f5664e3839ffc04db1315e8d9d07f8b956.tar.gz Qt-88fa17f5664e3839ffc04db1315e8d9d07f8b956.tar.bz2 |
Merge branch 'qt-graphics-team-qstatictext-4.7'
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 17 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 28 | ||||
-rw-r--r-- | src/gui/image/qpixmapfilter.cpp | 14 |
3 files changed, 46 insertions, 13 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index ac1d303..bf6eb8d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -104,6 +104,15 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1); +static void qt_cleanup_icon_cache(); +typedef QCache<QString, QIcon> IconCache; +Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache)) + +static void qt_cleanup_icon_cache() +{ + qtIconCache()->clear(); +} + QIconPrivate::QIconPrivate() : engine(0), ref(1), serialNum(serialNumCounter.fetchAndAddRelaxed(1)), @@ -963,15 +972,13 @@ QString QIcon::themeName() */ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) { - static QCache <QString, QIcon> iconCache; - QIcon icon; - if (iconCache.contains(name)) { - icon = *iconCache.object(name); + if (qtIconCache()->contains(name)) { + icon = *qtIconCache()->object(name); } else { QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name)); - iconCache.insert(name, cachedIcon); + qtIconCache()->insert(name, cachedIcon); icon = *cachedIcon; } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index c9e015c..9320cfc 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -263,25 +263,37 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, device->seek(pos); } - if (!handler && !testFormat.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) { + if (!handler && !testFormat.isEmpty() && !ignoresFormatAndExtension) { // check if any plugin supports the format (they are not allowed to // read from the device yet). const qint64 pos = device ? device->pos() : 0; - for (int i = 0; i < keys.size(); ++i) { - if (i != suffixPluginIndex) { - QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); - if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { + + if (autoDetectImageFormat) { + for (int i = 0; i < keys.size(); ++i) { + if (i != suffixPluginIndex) { + QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); + if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; + qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; #endif - handler = plugin->create(device, testFormat); - break; + handler = plugin->create(device, testFormat); + break; + } } } + } else { + QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QLatin1String(testFormat))); + if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { +#ifdef QIMAGEREADER_DEBUG + qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format"; +#endif + handler = plugin->create(device, testFormat); + } } if (device && !device->isSequential()) device->seek(pos); } + #endif // QT_NO_LIBRARY // if we don't have a handler yet, check if we have built-in support for diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 37a6a18..7cf942c 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -422,6 +422,9 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q if(d->kernelWidth<=0 || d->kernelHeight <= 0) return; + if (src.isNull()) + return; + QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter); @@ -902,6 +905,9 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap if (!painter->isActive()) return; + if (src.isNull()) + return; + QRectF srcRect = rect; if (srcRect.isNull()) srcRect = src.rect(); @@ -1082,6 +1088,10 @@ void QPixmapColorizeFilter::setStrength(qreal strength) void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const { Q_D(const QPixmapColorizeFilter); + + if (src.isNull()) + return; + QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter); @@ -1312,6 +1322,10 @@ void QPixmapDropShadowFilter::draw(QPainter *p, const QRectF &src) const { Q_D(const QPixmapDropShadowFilter); + + if (px.isNull()) + return; + QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ? static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter); |