summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--LGPL_EXCEPTION.txt22
-rw-r--r--src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp95
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp7
4 files changed, 77 insertions, 49 deletions
diff --git a/.qmake.conf b/.qmake.conf
index b2354e6..bc074d5 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -3,4 +3,4 @@ load(qt_build_config)
CONFIG += warning_clean
DEFINES += QT_NO_FOREACH
-MODULE_VERSION = 5.11.1
+MODULE_VERSION = 5.12.0
diff --git a/LGPL_EXCEPTION.txt b/LGPL_EXCEPTION.txt
deleted file mode 100644
index 5cdacb9..0000000
--- a/LGPL_EXCEPTION.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-The Qt Company Qt LGPL Exception version 1.1
-
-As an additional permission to the GNU Lesser General Public License version
-2.1, the object code form of a "work that uses the Library" may incorporate
-material from a header file that is part of the Library. You may distribute
-such object code under terms of your choice, provided that:
- (i) the header files of the Library have not been modified; and
- (ii) the incorporated material is limited to numerical parameters, data
- structure layouts, accessors, macros, inline functions and
- templates; and
- (iii) you comply with the terms of Section 6 of the GNU Lesser General
- Public License version 2.1.
-
-Moreover, you may apply this exception to a modified version of the Library,
-provided that such modification does not involve copying material from the
-Library into the modified Library's header files unless such material is
-limited to (i) numerical parameters; (ii) data structure layouts;
-(iii) accessors; and (iv) small macros, templates and inline functions of
-five lines or less in length.
-
-Furthermore, you are not required to apply this additional permission to a
-modified version of the Library.
diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
index 0c54e0e..e23dd9a 100644
--- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
+++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
@@ -74,7 +74,8 @@ public:
void stepSerialNum()
{ serialNum = lastSerialNum.fetchAndAddRelaxed(1); }
- void loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state);
+ bool tryLoad(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state);
+ QIcon::Mode loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state);
QHash<int, QString> svgFiles;
QHash<int, QByteArray> *svgBuffers;
@@ -121,31 +122,73 @@ QSize QSvgIconEngine::actualSize(const QSize &size, QIcon::Mode mode,
return pm.size();
}
-void QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
+static QByteArray maybeUncompress(const QByteArray &ba)
{
- QByteArray buf;
- const QIcon::State oppositeState = state == QIcon::Off ? QIcon::On : QIcon::Off;
- if (svgBuffers) {
- buf = svgBuffers->value(hashKey(mode, state));
- if (buf.isEmpty())
- buf = svgBuffers->value(hashKey(QIcon::Normal, state));
- if (buf.isEmpty())
- buf = svgBuffers->value(hashKey(QIcon::Normal, oppositeState));
- }
- if (!buf.isEmpty()) {
#ifndef QT_NO_COMPRESS
- buf = qUncompress(buf);
+ return qUncompress(ba);
+#else
+ return ba;
#endif
- renderer->load(buf);
+}
+
+bool QSvgIconEnginePrivate::tryLoad(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
+{
+ if (svgBuffers) {
+ QByteArray buf = svgBuffers->value(hashKey(mode, state));
+ if (!buf.isEmpty()) {
+ buf = maybeUncompress(buf);
+ renderer->load(buf);
+ return true;
+ }
+ }
+ QString svgFile = svgFiles.value(hashKey(mode, state));
+ if (!svgFile.isEmpty()) {
+ renderer->load(svgFile);
+ return true;
+ }
+ return false;
+}
+
+QIcon::Mode QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
+{
+ if (tryLoad(renderer, mode, state))
+ return mode;
+
+ const QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On;
+ if (mode == QIcon::Disabled || mode == QIcon::Selected) {
+ const QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled;
+ if (tryLoad(renderer, QIcon::Normal, state))
+ return QIcon::Normal;
+ if (tryLoad(renderer, QIcon::Active, state))
+ return QIcon::Active;
+ if (tryLoad(renderer, mode, oppositeState))
+ return mode;
+ if (tryLoad(renderer, QIcon::Normal, oppositeState))
+ return QIcon::Normal;
+ if (tryLoad(renderer, QIcon::Active, oppositeState))
+ return QIcon::Active;
+ if (tryLoad(renderer, oppositeMode, state))
+ return oppositeMode;
+ if (tryLoad(renderer, oppositeMode, oppositeState))
+ return oppositeMode;
} else {
- QString svgFile = svgFiles.value(hashKey(mode, state));
- if (svgFile.isEmpty())
- svgFile = svgFiles.value(hashKey(QIcon::Normal, state));
- if (svgFile.isEmpty())
- svgFile = svgFiles.value(hashKey(QIcon::Normal, oppositeState));
- if (!svgFile.isEmpty())
- renderer->load(svgFile);
+ const QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal;
+ if (tryLoad(renderer, oppositeMode, state))
+ return oppositeMode;
+ if (tryLoad(renderer, mode, oppositeState))
+ return mode;
+ if (tryLoad(renderer, oppositeMode, oppositeState))
+ return oppositeMode;
+ if (tryLoad(renderer, QIcon::Disabled, state))
+ return QIcon::Disabled;
+ if (tryLoad(renderer, QIcon::Selected, state))
+ return QIcon::Selected;
+ if (tryLoad(renderer, QIcon::Disabled, oppositeState))
+ return QIcon::Disabled;
+ if (tryLoad(renderer, QIcon::Selected, oppositeState))
+ return QIcon::Selected;
}
+ return QIcon::Normal;
}
QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
@@ -164,7 +207,7 @@ QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
}
QSvgRenderer renderer;
- d->loadDataForModeAndState(&renderer, mode, state);
+ const QIcon::Mode loadmode = d->loadDataForModeAndState(&renderer, mode, state);
if (!renderer.isValid())
return pm;
@@ -182,9 +225,11 @@ QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
p.end();
pm = QPixmap::fromImage(img);
if (qobject_cast<QGuiApplication *>(QCoreApplication::instance())) {
- const QPixmap generated = QGuiApplicationPrivate::instance()->applyQIconStyleHelper(mode, pm);
- if (!generated.isNull())
- pm = generated;
+ if (loadmode != mode && mode != QIcon::Normal) {
+ const QPixmap generated = QGuiApplicationPrivate::instance()->applyQIconStyleHelper(mode, pm);
+ if (!generated.isNull())
+ pm = generated;
+ }
}
if (!pm.isNull())
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index 457c79e..a999d47 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -176,8 +176,13 @@ bool QSvgIOHandler::read(QImage *image)
t.translate(tr1.x(), tr1.y());
bounds = t.mapRect(bounds);
}
- if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied))
+ if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)) {
*image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied);
+ if (!finalSize.isEmpty() && image->isNull()) {
+ qWarning("QSvgIOHandler: QImage allocation failed (size %i x %i)", finalSize.width(), finalSize.height());
+ return false;
+ }
+ }
if (!finalSize.isEmpty()) {
image->fill(d->backColor.rgba());
QPainter p(image);