From 1464118b67a030d290eb14e7c6612202273e1366 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Sep 2015 15:09:21 +0200 Subject: QIcon: add a hook in the engine so a non null QIconEngine can still be a null icon Implement it in the QIconLoader We have to change detach() because some code does: icon = QIcon::fromTheme("foobar"); if (icon.isNull()) icon.addPixmap(...); so addPixmap and addFile have to work on a null QIcon by resetting the iconEngine. Change-Id: I07719bef93930cf4692384a8c64e21a97dcce25c Reviewed-by: David Faure --- src/gui/image/qiconengine.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/gui/image/qiconengine.cpp') diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp index a25b216432..49a3bead53 100644 --- a/src/gui/image/qiconengine.cpp +++ b/src/gui/image/qiconengine.cpp @@ -143,6 +143,11 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI icon, for example when instantiating an icon using QIcon::fromTheme(). + \value IsNullHook Allow to query if this engine represents a null + icon. The \a data argument of the virtual_hook() is a pointer to a + bool that can be set to true if the icon is null. This enum value + was added in Qt 5.7. + \sa virtual_hook() */ @@ -276,4 +281,16 @@ QString QIconEngine::iconName() const return name; } +/*! + \since 5.7 + + Returns true if this icon engine represent a null QIcon. + */ +bool QIconEngine::isNull() const +{ + bool isNull = false; + const_cast(this)->virtual_hook(QIconEngine::IsNullHook, &isNull); + return isNull; +} + QT_END_NAMESPACE -- cgit v1.2.3