Killing containments that do not belong to any activity
Removing the legacy migration code which guesses what to do with containments that are not assigned to an activity. REVIEW:113919
This commit is contained in:
parent
0fb9549dea
commit
3dbb992e61
@ -536,79 +536,17 @@ void ShellCorona::checkActivities()
|
|||||||
activityAdded(id);
|
activityAdded(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList newActivities;
|
// Checking whether the result we got is valid. Just in case.
|
||||||
QString newCurrentActivity;
|
Q_ASSERT_X(existingActivities.isEmpty(), "isEmpty", "There are no activities, and the service is running");
|
||||||
//migration checks:
|
Q_ASSERT_X(existingActivities[0] != QStringLiteral("00000000-0000-0000-0000-000000000000"),
|
||||||
//-containments with an invalid id are deleted.
|
"null uuid", "There is a nulluuid activity present");
|
||||||
//-containments that claim they were on a screen are kept together, and are preferred if we
|
|
||||||
//need to initialize the current activity.
|
// Killing the unassigned containments
|
||||||
//-containments that don't know where they were or who they were with just get made into their
|
|
||||||
//own activity.
|
|
||||||
foreach(Plasma::Containment * cont, containments()) {
|
foreach(Plasma::Containment * cont, containments()) {
|
||||||
if ((cont->containmentType() == Plasma::Types::DesktopContainment ||
|
if ((cont->containmentType() == Plasma::Types::DesktopContainment ||
|
||||||
cont->containmentType() == Plasma::Types::CustomContainment)) {
|
cont->containmentType() == Plasma::Types::CustomContainment) &&
|
||||||
const QString oldId = cont->activity();
|
!existingActivities.contains(cont->activity())) {
|
||||||
if (!oldId.isEmpty()) {
|
|
||||||
if (existingActivities.contains(oldId)) {
|
|
||||||
continue; //it's already claimed
|
|
||||||
}
|
|
||||||
qDebug() << "invalid id" << oldId;
|
|
||||||
//byebye
|
|
||||||
cont->destroy();
|
cont->destroy();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cont->screen() > -1 && !newCurrentActivity.isEmpty()) {
|
|
||||||
//it belongs on the new current activity
|
|
||||||
cont->setActivity(newCurrentActivity);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*//discourage blank names
|
|
||||||
if (context->currentActivity().isEmpty()) {
|
|
||||||
context->setCurrentActivity(i18nc("Default name for a new activity", "New Activity"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//create a new activity for the containment
|
|
||||||
const QString id = d->activityController->addActivity(cont->activity());
|
|
||||||
cont->setActivity(id);
|
|
||||||
newActivities << id;
|
|
||||||
if (cont->screen() > -1) {
|
|
||||||
newCurrentActivity = id;
|
|
||||||
}
|
|
||||||
qDebug() << "migrated" << cont->id() << cont->activity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "migrated?" << !newActivities.isEmpty() << containments().count();
|
|
||||||
if (!newActivities.isEmpty()) {
|
|
||||||
requestConfigSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
//init the newbies
|
|
||||||
foreach (const QString &id, newActivities) {
|
|
||||||
activityAdded(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//ensure the current activity is initialized
|
|
||||||
if (d->activityController->currentActivity().isEmpty()) {
|
|
||||||
qDebug() << "guessing at current activity";
|
|
||||||
if (existingActivities.isEmpty()) {
|
|
||||||
if (newCurrentActivity.isEmpty()) {
|
|
||||||
if (newActivities.isEmpty()) {
|
|
||||||
qDebug() << "no activities!?! Bad activitymanager, no cookie!";
|
|
||||||
QString id = d->activityController->addActivity(i18nc("Default name for a new activity", "New Activity"));
|
|
||||||
activityAdded(id);
|
|
||||||
d->activityController->setCurrentActivity(id);
|
|
||||||
qDebug() << "created emergency activity" << id;
|
|
||||||
} else {
|
|
||||||
d->activityController->setCurrentActivity(newActivities.first());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
d->activityController->setCurrentActivity(newCurrentActivity);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
d->activityController->setCurrentActivity(existingActivities.first());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user