Commit bce33353 authored by Daniel Teske's avatar Daniel Teske

SessionManager: Be smarter about loading/unloading projects

On switching sessions don't unload projects that are in both
sessions.

Change-Id: Iceceea262677ab523f8c3c9d2dda64faa34d6e0d
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 8bef6359
......@@ -890,6 +890,8 @@ bool SessionManager::loadSession(const QString &session)
if (!sessions().contains(session))
return false;
QStringList fileList;
// Try loading the file
FileName fileName = sessionNameToFileName(session);
PersistentSettingsReader reader;
......@@ -897,8 +899,10 @@ bool SessionManager::loadSession(const QString &session)
if (!reader.load(fileName)) {
QMessageBox::warning(ICore::dialogParent(), tr("Error while restoring session"),
tr("Could not restore session %1").arg(fileName.toUserOutput()));
return false;
}
fileList = reader.restoreValue(QLatin1String("ProjectList")).toStringList();
}
d->m_loadingSession = true;
......@@ -920,7 +924,22 @@ bool SessionManager::loadSession(const QString &session)
}
setStartupProject(0);
removeProjects(projects());
QList<Project *> oldProjects = projects();
auto it = oldProjects.begin();
auto end = oldProjects.end();
while (it != end) {
int index = fileList.indexOf((*it)->document()->filePath().toString());
if (index != -1) {
fileList.removeAt(index);
it = oldProjects.erase(it);
} else {
++it;
}
}
removeProjects(oldProjects);
d->m_failedProjects.clear();
d->m_depMap.clear();
......@@ -950,9 +969,6 @@ bool SessionManager::loadSession(const QString &session)
if (c.isValid())
StyleHelper::setBaseColor(c);
QStringList fileList =
reader.restoreValue(QLatin1String("ProjectList")).toStringList();
d->m_future.setProgressRange(0, fileList.count() + 1/*initialization above*/ + 1/*editors*/);
d->m_future.setProgressValue(1);
......
Markdown is supported
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