diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -1906,7 +1906,8 @@ { Plasma::Containment *cont = nullptr; for (Plasma::Containment *c : m_desktopContainments.value(activity)) { - if (c->screen() == screenNum) { + //using lastScreen() instead of screen() catches also containments of activities that aren't the current one, so not assigned to a screen right now + if (c->lastScreen() == screenNum) { cont = c; if (containment == cont) { return; @@ -1918,8 +1919,8 @@ Q_ASSERT(!m_desktopContainments.value(activity).values().contains(containment)); if (cont) { - disconnect(cont, SIGNAL(destroyed(QObject*)), - this, SLOT(desktopContainmentDestroyed(QObject*))); + //NOTE: desktopContainmentDestroyed would remove it from m_desktopContainments as well, but seems this happens too late, by then the config of the containment gets saved again and some spurious data remains in the appletsrc file + m_desktopContainments[activity].remove(cont); cont->destroy(); } m_desktopContainments[activity].insert(containment);