diff --git a/src/lib/tools/iconprovider.cpp b/src/lib/tools/iconprovider.cpp index c8dd160ed..9588b900f 100644 --- a/src/lib/tools/iconprovider.cpp +++ b/src/lib/tools/iconprovider.cpp @@ -187,6 +187,8 @@ QImage IconProvider::imageForUrl(const QUrl &url, bool allowNull) return allowNull ? QImage() : IconProvider::emptyWebImage(); } + QMutexLocker locker(&instance()->m_iconCacheMutex); + const QByteArray encodedUrl = encodeUrl(url); if (QImage *img = instance()->m_urlImageCache.object(encodedUrl)) { @@ -224,6 +226,8 @@ QImage IconProvider::imageForDomain(const QUrl &url, bool allowNull) return allowNull ? QImage() : IconProvider::emptyWebImage(); } + QMutexLocker locker(&instance()->m_iconCacheMutex); + foreach (const BufferedIcon &ic, instance()->m_iconBuffer) { if (ic.first.host() == url.host()) { return ic.second; @@ -249,6 +253,8 @@ IconProvider* IconProvider::instance() void IconProvider::saveIconsToDatabase() { + QMutexLocker locker(&instance()->m_iconCacheMutex); + foreach (const BufferedIcon &ic, m_iconBuffer) { QByteArray ba; QBuffer buffer(&ba); diff --git a/src/lib/tools/iconprovider.h b/src/lib/tools/iconprovider.h index f033f2900..acf03ac66 100644 --- a/src/lib/tools/iconprovider.h +++ b/src/lib/tools/iconprovider.h @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -82,6 +83,7 @@ private: QIcon m_bookmarkIcon; QVector m_iconBuffer; QCache m_urlImageCache; + QMutex m_iconCacheMutex; AutoSaver* m_autoSaver; };