Commit a6461960 authored by Tobias Hunger's avatar Tobias Hunger

Session: Fix (un)loading of projects on session change

Task-number: QTCREATORBUG-19078
Change-Id: I4f527cb3af9b9270a65da1e283e8a1f3db737531
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 4acb1627
...@@ -1017,10 +1017,15 @@ bool SessionManager::loadSession(const QString &session) ...@@ -1017,10 +1017,15 @@ bool SessionManager::loadSession(const QString &session)
} }
// find a list of projects to close later // find a list of projects to close later
const QList<Project *> oldProjects = Utils::filtered(projects(), [&fileList](Project *p) { const QList<Project *> projectsToRemove = Utils::filtered(projects(), [&fileList](Project *p) {
return !fileList.contains(p->projectFilePath().toString()); return !fileList.contains(p->projectFilePath().toString());
});
const QList<Project *> openProjects = projects();
const QStringList projectPathsToLoad = Utils::filtered(fileList, [&openProjects](const QString &path) {
return !Utils::contains(openProjects, [&path](Project *p) {
return p->projectFilePath().toString() == path;
});
}); });
d->m_failedProjects.clear(); d->m_failedProjects.clear();
d->m_depMap.clear(); d->m_depMap.clear();
d->m_values.clear(); d->m_values.clear();
...@@ -1052,19 +1057,19 @@ bool SessionManager::loadSession(const QString &session) ...@@ -1052,19 +1057,19 @@ bool SessionManager::loadSession(const QString &session)
if (c.isValid()) if (c.isValid())
StyleHelper::setBaseColor(c); StyleHelper::setBaseColor(c);
d->m_future.setProgressRange(0, fileList.count() + 1/*initialization above*/ + 1/*editors*/); d->m_future.setProgressRange(0, projectPathsToLoad.count() + 1/*initialization above*/ + 1/*editors*/);
d->m_future.setProgressValue(1); d->m_future.setProgressValue(1);
// if one processEvents doesn't get the job done // if one processEvents doesn't get the job done
// just use two! // just use two!
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
d->restoreProjects(fileList); d->restoreProjects(projectPathsToLoad);
d->sessionLoadingProgress(); d->sessionLoadingProgress();
d->restoreDependencies(reader); d->restoreDependencies(reader);
d->restoreStartupProject(reader); d->restoreStartupProject(reader);
removeProjects(oldProjects); // only remove old projects now that the startup project is set! removeProjects(projectsToRemove); // only remove old projects now that the startup project is set!
d->restoreEditors(reader); d->restoreEditors(reader);
...@@ -1079,6 +1084,7 @@ bool SessionManager::loadSession(const QString &session) ...@@ -1079,6 +1084,7 @@ bool SessionManager::loadSession(const QString &session)
ModeManager::activateMode(modeId); ModeManager::activateMode(modeId);
ModeManager::setFocusToCurrentMode(); ModeManager::setFocusToCurrentMode();
} else { } else {
removeProjects(projects());
ModeManager::activateMode(Id(Core::Constants::MODE_EDIT)); ModeManager::activateMode(Id(Core::Constants::MODE_EDIT));
ModeManager::setFocusToCurrentMode(); ModeManager::setFocusToCurrentMode();
} }
......
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