Fixed tst_QIcon::task184901_badCache().
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 13 Sep 2011 12:34:03 +0000 (14:34 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Sep 2011 07:11:35 +0000 (09:11 +0200)
QIcon has not been moved to QtGui after all, re-introduce
QtWidgets-dependent code path.

Task-number: QTBUG-21402
Change-Id: I61c37babaeceadf7d53c10736bcc847758adaf1b
Reviewed-on: http://codereview.qt-project.org/4775
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/widgets/kernel/qicon.cpp
tests/auto/gui/image/qicon/qicon.pro

index ec8740b..bb9f56b 100644 (file)
@@ -54,7 +54,7 @@
 #include "qcache.h"
 #include "qdebug.h"
 #include "private/qguiplatformplugin_p.h"
-#include "qguiapplication.h"
+#include "qapplication.h"
 
 #ifdef Q_WS_MAC
 #include <private/qt_mac_p.h>
@@ -264,37 +264,37 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
         actualSize.scale(size, Qt::KeepAspectRatio);
 
     // #### Qt5 no idea what this really does, but we need to remove the QApp and style references
-//    QString key = QLatin1Literal("qt_")
-//                  % HexString<quint64>(pm.cacheKey())
-//                  % HexString<uint>(pe->mode)
-//                  % HexString<quint64>(QApplication::palette().cacheKey())
-//                  % HexString<uint>(actualSize.width())
-//                  % HexString<uint>(actualSize.height());
-
-//    if (mode == QIcon::Active) {
-//        if (QPixmapCache::find(key % HexString<uint>(mode), pm))
-//            return pm; // horray
-//        if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
-//            QStyleOption opt(0);
-//            opt.palette = QApplication::palette();
-//            QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt);
-//            if (pm.cacheKey() == active.cacheKey())
-//                return pm;
-//        }
-//    }
-
-//    if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
+    QString key = QLatin1Literal("qt_")
+                  % HexString<quint64>(pm.cacheKey())
+                  % HexString<uint>(pe->mode)
+                  % HexString<quint64>(QApplication::palette().cacheKey())
+                  % HexString<uint>(actualSize.width())
+                  % HexString<uint>(actualSize.height());
+
+    if (mode == QIcon::Active) {
+        if (QPixmapCache::find(key % HexString<uint>(mode), pm))
+            return pm; // horray
+        if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
+            QStyleOption opt(0);
+            opt.palette = QApplication::palette();
+            QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt);
+            if (pm.cacheKey() == active.cacheKey())
+                return pm;
+        }
+    }
+
+    if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
         if (pm.size() != actualSize)
             pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-//        if (pe->mode != mode && mode != QIcon::Normal) {
-//            QStyleOption opt(0);
-//            opt.palette = QApplication::palette();
-//            QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
-//            if (!generated.isNull())
-//                pm = generated;
-//        }
-//        QPixmapCache::insert(key % HexString<uint>(mode), pm);
-//    }
+        if (pe->mode != mode && mode != QIcon::Normal) {
+            QStyleOption opt(0);
+            opt.palette = QApplication::palette();
+            QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
+            if (!generated.isNull())
+                pm = generated;
+        }
+        QPixmapCache::insert(key % HexString<uint>(mode), pm);
+    }
     return pm;
 }
 
index 5ce4fd4..cc87fae 100644 (file)
@@ -28,5 +28,3 @@ wince* {
 } else {
    DEFINES += SRCDIR=\\\"$$PWD\\\"
 }
-
-CONFIG += insignificant_test # QTBUG-21402