From 501871d0c4155336f5ebe3842c7d0d453fc69ad8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Dec 2013 21:29:36 +0100 Subject: Get sure we try downloading just once engine favicon(s)... --- src/icons/iconmanager.cpp | 14 +++++++++++--- src/icons/iconmanager.h | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/icons/iconmanager.cpp b/src/icons/iconmanager.cpp index 7bc47eec..0a1645d7 100644 --- a/src/icons/iconmanager.cpp +++ b/src/icons/iconmanager.cpp @@ -209,12 +209,20 @@ QString IconManager::iconPathForUrl(const KUrl &url) KIcon IconManager::engineFavicon(const KUrl &url) { - if (QFile::exists(_faviconsDir + url.host() + QL1S(".png"))) - return KIcon(QIcon(_faviconsDir + url.host() + QL1S(".png"))); + QString h = url.host(); + if (QFile::exists(_faviconsDir + h + QL1S(".png"))) + { + _engineFaviconHosts.removeAll(h); + return KIcon(QIcon(_faviconsDir + h + QL1S(".png"))); + } // if engine favicon is NOT found, download it // will autodelete itself when done - new WebIcon(url); + if (!_engineFaviconHosts.contains(h)) + { + _engineFaviconHosts << h; + new WebIcon(url); + } kDebug() << "NO ENGINE FAVICON"; return KIcon("text-html"); diff --git a/src/icons/iconmanager.h b/src/icons/iconmanager.h index 659eff88..74cf706a 100644 --- a/src/icons/iconmanager.h +++ b/src/icons/iconmanager.h @@ -34,6 +34,7 @@ #include #include #include +#include // Forward Declarations class KIcon; @@ -68,7 +69,9 @@ private: QString _faviconsDir; QString _tempIconsDir; - + + QStringList _engineFaviconHosts; + static QWeakPointer s_iconManager; }; -- cgit v1.2.1