From ca1bf0e3e4c018127d2aac0a78a2e44385b76174 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 10 Oct 2016 16:46:59 +0200 Subject: [PATCH] fix screenForContainment when screen ids > count Summary: the check that was there, screen id not being more than screen count is not valid anymore with the screenpool approach, a screen id can be bigger than the screen count in cases such as middle screen of a 3 screen system disabled, or driver change (in which unfortunately, connector names can change) without this, a new containment was created for each startup. BUG:369665 Test Plan: created a puroposefully corrupted plasmashellrc file, where one known screen has a big number as id. without patch a new containment is added in appletsrc each time with the patch it behaves fine. Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: davidedmundson, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D3006 --- shell/shellcorona.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index 152ffebb4..3cc16145b 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -1798,11 +1798,12 @@ int ShellCorona::screenForContainment(const Plasma::Containment *containment) co //a containment with lastScreen() == 0 but another activity, //won't be associated to a screen // qDebug() << "ShellCorona screenForContainment: " << containment << " Last screen is " << containment->lastScreen(); - for (int i = 0, count = qGuiApp->screens().count(); ilastScreen() == i && + + for (auto screen : qGuiApp->screens()) { + if (containment->lastScreen() == m_screenPool->id(screen->name()) && (containment->activity() == m_activityController->currentActivity() || containment->containmentType() == Plasma::Types::PanelContainment || containment->containmentType() == Plasma::Types::CustomPanelContainment)) { - return i; + return containment->lastScreen(); } }