diff --git a/shell/shellcorona.h b/shell/shellcorona.h --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -200,7 +200,6 @@ void primaryOutputChanged(); void panelContainmentDestroyed(QObject* cont); - void desktopContainmentDestroyed(QObject*); void showOpenGLNotCompatibleWarning(); void interactiveConsoleVisibilityChanged(bool visible); void handleScreenRemoved(QScreen* screen); @@ -236,7 +235,6 @@ KConfigGroup m_lnfDefaultsConfig; QList m_waitingPanels; QHash m_activityContainmentPlugins; - QHash > m_desktopContainments; QAction *m_addPanelAction; QMenu *m_addPanelsMenu; KPackage::Package m_lookAndFeelPackage; diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -853,7 +853,6 @@ m_desktopViewforId.clear(); qDeleteAll(m_panelViews); m_panelViews.clear(); - m_desktopContainments.clear(); m_waitingPanels.clear(); m_activityContainmentPlugins.clear(); @@ -1233,16 +1232,14 @@ Plasma::Containment *ShellCorona::createContainmentForActivity(const QString& activity, int screenNum) { - if (m_desktopContainments.contains(activity)) { - for (Plasma::Containment *cont : m_desktopContainments.value(activity)) { - //in the case of a corrupt config file - //with multiple containments with same lastScreen - //it can happen two insertContainment happen for - //the same screen, leading to the old containment - //to be destroyed - if (!cont->destroyed() && cont->screen() == screenNum && cont->activity() == activity) { - return cont; - } + for (Plasma::Containment *cont : containmentsForActivity(activity)) { + //in the case of a corrupt config file + //with multiple containments with same lastScreen + //it can happen two insertContainment happen for + //the same screen, leading to the old containment + //to be destroyed + if (!cont->destroyed() && cont->screen() == screenNum) { + return cont; } } @@ -1252,11 +1249,10 @@ plugin = defaultContainmentPlugin(); } - Plasma::Containment *containment = containmentForScreen(screenNum, plugin, QVariantList()); + Plasma::Containment *containment = containmentForScreen(screenNum, activity, plugin, QVariantList()); Q_ASSERT(containment); if (containment) { - containment->setActivity(activity); insertContainment(activity, screenNum, containment); } @@ -1556,10 +1552,8 @@ void ShellCorona::activityRemoved(const QString &id) { m_activityContainmentPlugins.remove(id); - if (m_desktopContainments.contains(id)) { - for (auto cont : m_desktopContainments.value(id)) { - cont->destroy(); - } + for (auto cont : containmentsForActivity(id)) { + cont->destroy(); } } @@ -1596,7 +1590,8 @@ Plasma::Containment *ShellCorona::setContainmentTypeForScreen(int screen, const QString &plugin) { - Plasma::Containment *oldContainment = containmentForScreen(screen); + //search but not create + Plasma::Containment *oldContainment = containmentForScreen(screen, m_activityController->currentActivity(), QString()); //no valid containment in given screen, giving up if (!oldContainment) { @@ -1675,7 +1670,6 @@ } view->setContainment(newContainment); newContainment->setActivity(oldContainment->activity()); - m_desktopContainments.remove(oldContainment->activity()); insertContainment(oldContainment->activity(), screen, newContainment); //removing the focus from the item that is going to be destroyed @@ -1946,7 +1940,8 @@ void ShellCorona::insertContainment(const QString &activity, int screenNum, Plasma::Containment *containment) { Plasma::Containment *cont = nullptr; - for (Plasma::Containment *c : m_desktopContainments.value(activity)) { + auto candidates = containmentsForActivity(activity); + for (Plasma::Containment *c : candidates) { //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; @@ -1957,34 +1952,12 @@ } } - Q_ASSERT(!m_desktopContainments.value(activity).values().contains(containment)); + Q_ASSERT(candidates.contains(containment)); + Q_ASSERT(containment != cont); if (cont) { cont->destroy(); } - m_desktopContainments[activity].insert(containment); - - //when a containment gets deleted update our map of containments - connect(containment, SIGNAL(destroyed(QObject*)), this, SLOT(desktopContainmentDestroyed(QObject*))); -} - -void ShellCorona::desktopContainmentDestroyed(QObject *obj) -{ - // when QObject::destroyed arrives, ~Plasma::Containment has run, - // members of Containment are not accessible anymore, - // so keep ugly bookeeping by hand - auto containment = static_cast(obj); - //explicitly specify the range by reference, as we need to remove stuff from the sets - for (QSet &a : m_desktopContainments) { - QMutableSetIterator it(a); - while (it.hasNext()) { - it.next(); - if (it.value() == containment) { - it.remove(); - return; - } - } - } } void ShellCorona::showOpenGLNotCompatibleWarning()