Commit 272e7640 authored by dt's avatar dt
Browse files

Make default virgin session check more robust.

Task-Nr: QTCREATORBUG-572
parent 336cb970
......@@ -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"
......@@ -173,7 +173,7 @@ private slots:
void handleCurrentEditorChange(Core::IEditor *editor);
void updateWindowTitle();
void markSessionFileDirty();
void markSessionFileDirty(bool makeDefaultVirginDirty = true);
private:
bool loadImpl(const QString &fileName);
......@@ -195,6 +195,7 @@ private:
QPointer<Core::IEditor> m_currentEditor;
QString m_displayName;
QString m_sessionName;
bool m_defaultVirginSession;
mutable QStringList m_sessions;
......
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