[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kdeui
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2010-06-20 9:17:08
Message-ID: 20100620091708.5F711AC8D9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1140316 by gateau:

Always clear path_store if no icon is found and canReturnNull is set.

 M  +4 -5      icons/kiconloader.cpp  
 M  +20 -0     tests/kiconloader_unittest.cpp  


--- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #1140315:1140316
@@ -1217,17 +1217,16 @@
     K3Icon icon;
 
     if (d->findCachedPixmapWithPath(key, pix, icon.path)) {
+        if (path_store) {
+            *path_store = icon.path;
+        }
+
         // We cache the pixmap for the event of trying to find an unknown icon
         // with canReturnNull set to false, but if we *can* return null then
         // we should do so when necessary.
         if (canReturnNull && icon.path.isEmpty()) {
             return QPixmap();
         }
-
-        if (path_store) {
-            *path_store = icon.path;
-        }
-
         return pix;
     }
 
--- trunk/KDE/kdelibs/kdeui/tests/kiconloader_unittest.cpp #1140315:1140316
@@ -183,6 +183,26 @@
         QVERIFY(!pix.isNull());
         QCOMPARE(path2, path);
     }
+
+    void testPathStore()
+    {
+        QString path;
+        KIconLoader::global()->loadIcon("kde", KIconLoader::Desktop, 24,
+                                        KIconLoader::DefaultState, QStringList(),
+                                        &path);
+        QVERIFY(!path.isEmpty());
+
+        KIconLoader::global()->loadIcon("does_not_exist", KIconLoader::Desktop, 24,
+                                        KIconLoader::DefaultState, QStringList(),
+                                        &path, true /* canReturnNull */);
+        QVERIFY(path.isEmpty());
+
+        path= "some filler to check loadIcon() clears the variable";
+        KIconLoader::global()->loadIcon("does_not_exist", KIconLoader::Desktop, 24,
+                                        KIconLoader::DefaultState, QStringList(),
+                                        &path, true /* canReturnNull */);
+        QVERIFY(path.isEmpty());
+    }
 };
 
 QTEST_KDEMAIN(KIconLoader_UnitTest, GUI)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic