diff --git a/wallpapers/image/backgroundlistmodel.h b/wallpapers/image/backgroundlistmodel.h --- a/wallpapers/image/backgroundlistmodel.h +++ b/wallpapers/image/backgroundlistmodel.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -144,7 +145,8 @@ QStringList m_paths; QString m_token; - static QStringList m_suffixes; + static QMutex s_suffixMutex; + static QStringList s_suffixes; }; #endif // BACKGROUNDLISTMODEL_H diff --git a/wallpapers/image/backgroundlistmodel.cpp b/wallpapers/image/backgroundlistmodel.cpp --- a/wallpapers/image/backgroundlistmodel.cpp +++ b/wallpapers/image/backgroundlistmodel.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -48,7 +50,8 @@ #include "image.h" -QStringList BackgroundFinder::m_suffixes; +QStringList BackgroundFinder::s_suffixes; +QMutex BackgroundFinder::s_suffixMutex; ImageSizeFinder::ImageSizeFinder(const QString &path, QObject *parent) : QObject(parent), @@ -514,7 +517,8 @@ const QStringList &BackgroundFinder::suffixes() { - if (m_suffixes.isEmpty()) { + QMutexLocker lock(&s_suffixMutex); + if (s_suffixes.isEmpty()) { QSet suffixes; QMimeDatabase db; @@ -525,10 +529,10 @@ } } - m_suffixes = suffixes.toList(); + s_suffixes = suffixes.toList(); } - return m_suffixes; + return s_suffixes; } bool BackgroundFinder::isAcceptableSuffix(const QString &suffix)