forked from qt-creator/qt-creator
Proj. explorer: Adjust order of load/unload signals
This tries to fix inconsistencies concerning the order of some signals and the corresponding state of the sessions. In particular, it now emittes aboutToLoadSession *after* aboutToUnloadSession. Also, retrieving the active session name gives the correct result when updating project files. In addition, there's a new parameter to aboutToLoadSession which describes the session being loaded. Change-Id: Iab5fb21080a7ee9bbf9f4d8958499cbc5549e81e Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -554,6 +554,9 @@ bool SessionManager::createImpl(const QString &fileName)
|
||||
emit aboutToUnloadSession();
|
||||
delete m_file;
|
||||
m_file = new SessionFile;
|
||||
const QString &sessionName = sessionNameFromFileName(fileName);
|
||||
emit aboutToLoadSession(sessionName);
|
||||
updateName(sessionName);
|
||||
m_file->setFileName(fileName);
|
||||
setStartupProject(0);
|
||||
|
||||
@@ -561,6 +564,8 @@ bool SessionManager::createImpl(const QString &fileName)
|
||||
ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
|
||||
ModeManager::instance()->setFocusToCurrentMode();
|
||||
}
|
||||
|
||||
emit sessionLoaded();
|
||||
}
|
||||
|
||||
m_virginSession = true;
|
||||
@@ -594,6 +599,9 @@ bool SessionManager::loadImpl(const QString &fileName)
|
||||
emit aboutToUnloadSession();
|
||||
delete m_file;
|
||||
m_file = new SessionFile;
|
||||
const QString &sessionName = sessionNameFromFileName(fileName);
|
||||
emit aboutToLoadSession(sessionName);
|
||||
updateName(sessionName);
|
||||
if (!m_file->load(fileName)) {
|
||||
QMessageBox::warning(0, tr("Error while restoring session"),
|
||||
tr("Could not restore session %1").arg(fileName));
|
||||
@@ -631,6 +639,8 @@ bool SessionManager::loadImpl(const QString &fileName)
|
||||
|
||||
ModeManager::instance()->activateMode(modeIdentifier);
|
||||
ModeManager::instance()->setFocusToCurrentMode();
|
||||
|
||||
emit sessionLoaded();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@@ -972,16 +982,20 @@ QString SessionManager::sessionNameToFileName(const QString &session) const
|
||||
return m_core->userResourcePath() + '/' + session + ".qws";
|
||||
}
|
||||
|
||||
QString SessionManager::sessionNameFromFileName(const QString &fileName) const
|
||||
{
|
||||
const int slash = fileName.lastIndexOf('/');
|
||||
Q_ASSERT(slash != -1 && fileName.endsWith(".qws"));
|
||||
return fileName.mid(slash + 1, fileName.length() - slash - 5); // Exclude .qws
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Creates a new default session and switches to it.
|
||||
*/
|
||||
|
||||
void SessionManager::createAndLoadNewDefaultSession()
|
||||
{
|
||||
emit aboutToLoadSession();
|
||||
updateName("default");
|
||||
createImpl(sessionNameToFileName(m_sessionName));
|
||||
emit sessionLoaded();
|
||||
createImpl(sessionNameToFileName("default"));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1050,23 +1064,13 @@ bool SessionManager::loadSession(const QString &session)
|
||||
|
||||
if (!sessions().contains(session))
|
||||
return false;
|
||||
emit aboutToLoadSession();
|
||||
|
||||
QString fileName = sessionNameToFileName(session);
|
||||
if (QFileInfo(fileName).exists()) {
|
||||
if (loadImpl(fileName)) {
|
||||
updateName(session);
|
||||
emit sessionLoaded();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Create a new session with that name
|
||||
if (!createImpl(sessionNameToFileName(session)))
|
||||
return false;
|
||||
updateName(session);
|
||||
emit sessionLoaded();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (QFileInfo(fileName).exists())
|
||||
return loadImpl(fileName);
|
||||
|
||||
// Create a new session with that name
|
||||
return createImpl(sessionNameToFileName(session));
|
||||
}
|
||||
|
||||
QString SessionManager::lastSession() const
|
||||
|
||||
Reference in New Issue
Block a user