Commit c7cb3ced authored by Marco Martin's avatar Marco Martin
Browse files

Revert "Revert "remove m_desktopContainments""

This reverts commit a122195a.
parent a122195a
......@@ -853,7 +853,6 @@ void ShellCorona::unload()
m_desktopViewforId.clear();
qDeleteAll(m_panelViews);
m_panelViews.clear();
m_desktopContainments.clear();
m_waitingPanels.clear();
m_activityContainmentPlugins.clear();
......@@ -1233,16 +1232,14 @@ void ShellCorona::addOutput(QScreen* screen)
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 @@ Plasma::Containment *ShellCorona::createContainmentForActivity(const QString& ac
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::activityAdded(const QString &id)
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 @@ void ShellCorona::insertActivity(const QString &id, const QString &plugin)
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 @@ Plasma::Containment *ShellCorona::setContainmentTypeForScreen(int screen, const
}
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::stopCurrentActivity()
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 @@ void ShellCorona::insertContainment(const QString &activity, int screenNum, Plas
}
}
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<Plasma::Containment*>(obj);
//explicitly specify the range by reference, as we need to remove stuff from the sets
for (QSet<Plasma::Containment *> &a : m_desktopContainments) {
QMutableSetIterator<Plasma::Containment *> it(a);
while (it.hasNext()) {
it.next();
if (it.value() == containment) {
it.remove();
return;
}
}
}
}
void ShellCorona::showOpenGLNotCompatibleWarning()
......
......@@ -200,7 +200,6 @@ private Q_SLOTS:
void primaryOutputChanged();
void panelContainmentDestroyed(QObject* cont);
void desktopContainmentDestroyed(QObject*);
void showOpenGLNotCompatibleWarning();
void interactiveConsoleVisibilityChanged(bool visible);
void handleScreenRemoved(QScreen* screen);
......@@ -236,7 +235,6 @@ private:
KConfigGroup m_lnfDefaultsConfig;
QList<Plasma::Containment *> m_waitingPanels;
QHash<QString, QString> m_activityContainmentPlugins;
QHash<QString, QSet<Plasma::Containment *> > m_desktopContainments;
QAction *m_addPanelAction;
QMenu *m_addPanelsMenu;
KPackage::Package m_lookAndFeelPackage;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment