From 671bcee7ce9ca602f9f4d55a3e5cac20c3e66964 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 20 Mar 2022 16:02:52 +0200 Subject: [PATCH] plasma: remove code for always false condition QUuid().toString() does not create random UUID string, it is always {00000000-0000-0000-0000-000000000000} Signed-off-by: Ivailo Monev --- .../core/tests/dynamictreemodel.cpp | 1 - plasma/wallpapers/image/backgroundlistmodel.cpp | 21 ++---------- plasma/wallpapers/image/backgroundlistmodel.h | 6 +--- plasma/wallpapers/image/image.cpp | 38 ++++++---------------- plasma/wallpapers/image/image.h | 4 +-- 5 files changed, 15 insertions(+), 55 deletions(-) diff --git a/plasma/declarativeimports/core/tests/dynamictreemodel.cpp b/plasma/declarativeimports/core/tests/dynamictreemodel.cpp index fa634b6a..a7eb87c5 100644 --- a/plasma/declarativeimports/core/tests/dynamictreemodel.cpp +++ b/plasma/declarativeimports/core/tests/dynamictreemodel.cpp @@ -213,7 +213,6 @@ void ModelInsertCommand::doCommand() { m_model->m_childItems[parentId].append(QList()); } -// QString name = QUuid::createUuid().toString(); qint64 id = m_model->newId(); QString name = QString::number(id); diff --git a/plasma/wallpapers/image/backgroundlistmodel.cpp b/plasma/wallpapers/image/backgroundlistmodel.cpp index bf05adb4..3f709c2c 100644 --- a/plasma/wallpapers/image/backgroundlistmodel.cpp +++ b/plasma/wallpapers/image/backgroundlistmodel.cpp @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -98,18 +97,10 @@ void BackgroundListModel::reload(const QStringList &selected) const QStringList dirs = KGlobal::dirs()->findDirs("wallpaper", ""); kDebug() << "going looking in" << dirs; BackgroundFinder *finder = new BackgroundFinder(m_structureParent.data(), dirs); - connect(finder, SIGNAL(backgroundsFound(QStringList,QString)), this, SLOT(backgroundsFound(QStringList,QString))); - m_findToken = finder->token(); + connect(finder, SIGNAL(backgroundsFound(QStringList)), this, SLOT(processPaths(QStringList))); finder->start(); } -void BackgroundListModel::backgroundsFound(const QStringList &paths, const QString &token) -{ - if (token == m_findToken) { - processPaths(paths); - } -} - void BackgroundListModel::processPaths(const QStringList &paths) { if (!m_structureParent) { @@ -338,8 +329,7 @@ void BackgroundListModel::setResizeMethod(Plasma::Wallpaper::ResizeMethod resize BackgroundFinder::BackgroundFinder(Plasma::Wallpaper *structureParent, const QStringList &paths) : QThread(structureParent), m_structure(Plasma::Wallpaper::packageStructure(structureParent)), - m_paths(paths), - m_token(QUuid().toString()) + m_paths(paths) { } @@ -348,11 +338,6 @@ BackgroundFinder::~BackgroundFinder() wait(); } -QString BackgroundFinder::token() const -{ - return m_token; -} - QStringList BackgroundFinder::suffixes() { return KImageIO::types(KImageIO::Reading); @@ -406,7 +391,7 @@ void BackgroundFinder::run() } //kDebug() << "background found!" << papersFound.size() << "in" << i << "dirs, taking" << t.elapsed() << "ms"; - emit backgroundsFound(papersFound, m_token); + emit backgroundsFound(papersFound); deleteLater(); } diff --git a/plasma/wallpapers/image/backgroundlistmodel.h b/plasma/wallpapers/image/backgroundlistmodel.h index bd660836..94b73775 100644 --- a/plasma/wallpapers/image/backgroundlistmodel.h +++ b/plasma/wallpapers/image/backgroundlistmodel.h @@ -70,7 +70,6 @@ protected Q_SLOTS: void showPreview(const KFileItem &item, const QPixmap &preview); void previewFailed(const KFileItem &item); void sizeFound(const QString &path, const QSize &s); - void backgroundsFound(const QStringList &paths, const QString &token); void processPaths(const QStringList &paths); private: @@ -85,7 +84,6 @@ private: QSize m_size; Plasma::Wallpaper::ResizeMethod m_resizeMethod; - QString m_findToken; QPixmap m_previewUnavailablePix; }; @@ -97,12 +95,10 @@ public: BackgroundFinder(Plasma::Wallpaper *structureParent, const QStringList &p); ~BackgroundFinder(); - QString token() const; - static QStringList suffixes(); signals: - void backgroundsFound(const QStringList &paths, const QString &token); + void backgroundsFound(const QStringList &paths); protected: void run(); diff --git a/plasma/wallpapers/image/image.cpp b/plasma/wallpapers/image/image.cpp index 58b0485e..32544641 100644 --- a/plasma/wallpapers/image/image.cpp +++ b/plasma/wallpapers/image/image.cpp @@ -41,7 +41,6 @@ Image::Image(QObject *parent, const QVariantList &args) : Plasma::Wallpaper(parent, args), m_delay(10), m_dirWatch(0), - m_scanDirty(false), m_configWidget(0), m_wallpaperPackage(0), m_currentSlide(-1), @@ -551,36 +550,19 @@ void Image::startSlideshow() return; } - if (m_findToken.isEmpty()) { - // populate background list - m_timer.stop(); - m_slideshowBackgrounds.clear(); - m_unseenSlideshowBackgrounds.clear(); - BackgroundFinder *finder = new BackgroundFinder(this, m_dirs); - m_findToken = finder->token(); - connect(finder, SIGNAL(backgroundsFound(QStringList,QString)), this, SLOT(backgroundsFound(QStringList,QString))); - finder->start(); - //TODO: what would be cool: paint on the wallpaper itself a busy widget and perhaps some text - //about loading wallpaper slideshow while the thread runs - } else { - m_scanDirty = true; - } + // populate background list + m_timer.stop(); + m_slideshowBackgrounds.clear(); + m_unseenSlideshowBackgrounds.clear(); + BackgroundFinder *finder = new BackgroundFinder(this, m_dirs); + connect(finder, SIGNAL(backgroundsFound(QStringList)), this, SLOT(backgroundsFound(QStringList))); + finder->start(); + //TODO: what would be cool: paint on the wallpaper itself a busy widget and perhaps some text + //about loading wallpaper slideshow while the thread runs } -void Image::backgroundsFound(const QStringList &paths, const QString &token) +void Image::backgroundsFound(const QStringList &paths) { - if (token != m_findToken) { - return; - } - - m_findToken.clear(); - - if(m_scanDirty) { - m_scanDirty = false; - startSlideshow(); - return; - } - m_slideshowBackgrounds = paths; m_unseenSlideshowBackgrounds.clear(); updateWallpaperActions(); diff --git a/plasma/wallpapers/image/image.h b/plasma/wallpapers/image/image.h index 4a63c286..1d71c098 100644 --- a/plasma/wallpapers/image/image.h +++ b/plasma/wallpapers/image/image.h @@ -82,7 +82,7 @@ class Image : public Plasma::Wallpaper void pathCreated(const QString &path); void pathDirty(const QString &path); void pathDeleted(const QString &path); - void backgroundsFound(const QStringList &paths, const QString &token); + void backgroundsFound(const QStringList &paths); bool checkSize(); void actuallyRenderWallpaper(); @@ -105,7 +105,6 @@ class Image : public Plasma::Wallpaper QColor m_color; QStringList m_usersWallpapers; KDirWatch *m_dirWatch; - bool m_scanDirty; QWidget* m_configWidget; Ui::ImageConfig m_uiImage; @@ -126,7 +125,6 @@ class Image : public Plasma::Wallpaper KFileDialog *m_dialog; QSize m_size; QString m_img; - QString m_findToken; QAction* m_nextWallpaperAction; QAction* m_openImageAction; -- 2.11.0