Make default virgin session check more robust.

Task-Nr: QTCREATORBUG-572
This commit is contained in:
dt
2010-03-18 13:42:09 +01:00
parent 336cb97089
commit 272e76409d
2 changed files with 15 additions and 8 deletions

View File

@@ -370,7 +370,8 @@ SessionManager::SessionManager(QObject *parent)
m_core(Core::ICore::instance()),
m_file(new SessionFile),
m_sessionNode(new Internal::SessionNodeImpl(this)),
m_currentEditor(0)
m_currentEditor(0),
m_defaultVirginSession(true)
{
// Create qtcreator dir if it doesn't yet exist
QString configDir = QFileInfo(m_core->settings()->fileName()).path();
@@ -424,9 +425,7 @@ SessionManager::~SessionManager()
bool SessionManager::isDefaultVirgin() const
{
return isDefaultSession(m_sessionName)
&& projects().isEmpty()
&& m_core->editorManager()->openedEditors().isEmpty();
return m_defaultVirginSession;
}
bool SessionManager::isDefaultSession(const QString &session) const
@@ -564,6 +563,7 @@ void SessionManager::addProject(Project *project)
void SessionManager::addProjects(const QList<Project*> &projects)
{
m_defaultVirginSession = false;
QList<Project*> clearedList;
foreach (Project *pro, projects) {
if (!m_file->m_projects.contains(pro)) {
@@ -594,6 +594,7 @@ void SessionManager::addProjects(const QList<Project*> &projects)
void SessionManager::removeProject(Project *project)
{
m_defaultVirginSession = false;
if (project == 0) {
qDebug() << "SessionManager::removeProject(0) ... THIS SHOULD NOT HAPPEN";
return;
@@ -623,6 +624,8 @@ bool SessionManager::createImpl(const QString &fileName)
setStartupProject(defaultStartupProject());
}
m_defaultVirginSession = false;
if (debug)
qDebug() << "SessionManager - creating new session returns " << success;
@@ -642,7 +645,6 @@ bool SessionManager::loadImpl(const QString &fileName)
bool success = true;
if (!m_file->fileName().isEmpty()) {
if (isDefaultVirgin()) {
// do not save initial and virgin default session
} else if (!save() || !clear()) {
@@ -650,6 +652,8 @@ bool SessionManager::loadImpl(const QString &fileName)
}
}
m_defaultVirginSession = false;
if (success) {
emit aboutToUnloadSession();
delete m_file;
@@ -1008,7 +1012,7 @@ void SessionManager::setValue(const QString &name, const QVariant &value)
if (m_file->m_values.value(name) == value)
return;
m_file->m_values.insert(name, value);
markSessionFileDirty();
markSessionFileDirty(false);
}
QVariant SessionManager::value(const QString &name)
@@ -1135,10 +1139,12 @@ void SessionManager::reportProjectLoadingProgress()
m_file->sessionLoadingProgress();
}
void SessionManager::markSessionFileDirty()
void SessionManager::markSessionFileDirty(bool makeDefaultVirginDirty)
{
if (m_file && !m_file->fileName().isEmpty())
m_autoSaveSessionTimer->start();
if (makeDefaultVirginDirty)
m_defaultVirginSession = false;
}
#include "session.moc"