Simplfy logic in SessionManager::loadImpl

Removing the bool success makes later refactorings easier to do. The
code flow is the same, except that the block handling failedProjects
after load was always run, even if SessionFile::load returned false.
The only place SessionFile::load returns false failedProjects didn't yet
change, so the code was wrong before.

Change-Id: I8ce565791d67ece7ab8fc7c4a799ed365153e34b
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Daniel Teske
2012-02-06 16:19:26 +01:00
parent 8b519d5ebc
commit 95896242de

View File

@@ -500,16 +500,17 @@ bool SessionManager::loadImpl(const QString &fileName)
if (debug) if (debug)
qDebug() << "SessionManager - restoring session " << fileName << " ..."; qDebug() << "SessionManager - restoring session " << fileName << " ...";
bool success = true;
if (isDefaultVirgin()) { if (isDefaultVirgin()) {
// do not save initial and virgin default session // do not save initial and virgin default session
} else if (!save() || !clear()) { } else if (!save() || !clear()) {
success = false; m_virginSession = false;
if (debug)
qDebug() << "SessionManager - restoring session returned " << false;
return false;
} }
m_virginSession = false; m_virginSession = false;
if (success) {
emit aboutToUnloadSession(); emit aboutToUnloadSession();
delete m_file; delete m_file;
m_file = new SessionFile; m_file = new SessionFile;
@@ -520,7 +521,10 @@ bool SessionManager::loadImpl(const QString &fileName)
if (!m_file->load(fileName)) { if (!m_file->load(fileName)) {
QMessageBox::warning(0, tr("Error while restoring session"), QMessageBox::warning(0, tr("Error while restoring session"),
tr("Could not restore session %1").arg(fileName)); tr("Could not restore session %1").arg(fileName));
success = false; if (debug)
qDebug() << "SessionManager - restoring session returned " << false;
return false;
} }
// m_file->load() sets the m_file->startupProject // m_file->load() sets the m_file->startupProject
// but doesn't emit this signal, so we do it here // but doesn't emit this signal, so we do it here
@@ -544,9 +548,7 @@ bool SessionManager::loadImpl(const QString &fileName)
if (box->clickedButton() == removeButton) if (box->clickedButton() == removeButton)
m_file->clearFailedProjectFileNames(); m_file->clearFailedProjectFileNames();
} }
}
if (success) {
// restore the active mode // restore the active mode
QString modeIdentifier = value(QLatin1String("ActiveMode")).toString(); QString modeIdentifier = value(QLatin1String("ActiveMode")).toString();
if (modeIdentifier.isEmpty()) if (modeIdentifier.isEmpty())
@@ -556,12 +558,11 @@ bool SessionManager::loadImpl(const QString &fileName)
ModeManager::setFocusToCurrentMode(); ModeManager::setFocusToCurrentMode();
emit sessionLoaded(); emit sessionLoaded();
}
if (debug) if (debug)
qDebug() << "SessionManager - restoring session returned " << success; qDebug() << "SessionManager - restoring session returned " << true;
return success; return true;
} }
bool SessionManager::save() bool SessionManager::save()