From a6bc63103ed128ffe0fd843eb3c4416ede835fde Mon Sep 17 00:00:00 2001 From: Harald Sitter Date: Mon, 6 Nov 2023 23:24:57 +0100 Subject: [PATCH] foldermodel: lift screen add/remove handling out of screenmapper screenmapper is the wrong place for it because we don't know the url inside the mapper. Instead handle events in the foldermodel and correctly delegate the add/remove actions to the mapper with both our screenId AND the activityId notably the previous code would incorrectly invoke addScreen with empty activityIds triggering fallback handling that resulted in incorrect m_screensPerPath management (there would be no screen associated with our url anymore after a screenAdded signal because our screen got associated with no url) and consequently firstAvailableScreen would return no screen for our url (remember: we are associated with no url) making FolderModel::filterAcceptsRow return false and filtering completely valid entries BUG: 467951 possibly also is the root cause behind CCBUG: 467092 --- containments/desktop/plugins/folder/foldermodel.cpp | 12 +++++++++++- containments/desktop/plugins/folder/screenmapper.cpp | 9 +-------- containments/desktop/plugins/folder/screenmapper.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp index 6a9f8da607..bcab0275e3 100644 --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -2024,7 +2024,17 @@ void FolderModel::setAppletInterface(QObject *appletInterface) Plasma::Corona *corona = containment->corona(); if (corona) { - m_screenMapper->setCorona(corona, m_currentActivity); + connect(corona, &Plasma::Corona::screenRemoved, this, [this](int screenId) { + if (m_screen == screenId) { + m_screenMapper->removeScreen(screenId, m_currentActivity, resolvedUrl()); + } + }); + connect(corona, &Plasma::Corona::screenAdded, this, [this](int screenId) { + if (m_screen == screenId) { + m_screenMapper->addScreen(screenId, m_currentActivity, resolvedUrl()); + } + }); + m_screenMapper->setCorona(corona); } setScreen(containment->screen()); connect(containment, &Plasma::Containment::screenChanged, this, &FolderModel::setScreen); diff --git a/containments/desktop/plugins/folder/screenmapper.cpp b/containments/desktop/plugins/folder/screenmapper.cpp index 83e8a75276..fccea0e3fe 100644 --- a/containments/desktop/plugins/folder/screenmapper.cpp +++ b/containments/desktop/plugins/folder/screenmapper.cpp @@ -243,20 +243,13 @@ void ScreenMapper::cleanup() } #endif -void ScreenMapper::setCorona(Plasma::Corona *corona, const QString &activity) +void ScreenMapper::setCorona(Plasma::Corona *corona) { if (m_corona != corona) { Q_ASSERT(!m_corona); m_corona = corona; if (m_corona) { - connect(m_corona, &Plasma::Corona::screenRemoved, this, [this, activity](int screenId) { - removeScreen(screenId, activity, {}); - }); - connect(m_corona, &Plasma::Corona::screenAdded, this, [this, activity](int screenId) { - addScreen(screenId, activity, {}); - }); - auto config = m_corona->config(); KConfigGroup group(config, QStringLiteral("ScreenMapping")); const QStringList mapping = group.readEntry(QStringLiteral("screenMapping"), QStringList{}); diff --git a/containments/desktop/plugins/folder/screenmapper.h b/containments/desktop/plugins/folder/screenmapper.h index 47b01e1c08..c22432b2e8 100644 --- a/containments/desktop/plugins/folder/screenmapper.h +++ b/containments/desktop/plugins/folder/screenmapper.h @@ -50,7 +50,7 @@ public: int screenForItem(const QUrl &url, const QString &activity) const; void addMapping(const QUrl &url, int screen, const QString &activity, MappingSignalBehavior behavior = ImmediateSignal); void removeFromMap(const QUrl &url, const QString &activity); - void setCorona(Plasma::Corona *corona, const QString &activity); + void setCorona(Plasma::Corona *corona); void addScreen(int screenId, const QString &activity, const QUrl &screenUrl); void removeScreen(int screenId, const QString &activity, const QUrl &screenUrl); -- GitLab