forked from qt-creator/qt-creator
Move SessionFile::m_startupProject to SessionManager
Preserve the exact same semantics, that is set it to 0 even if it is later overriden anyway. Note, this 0 setting prevents the startup project changed signal from being emitted, so it's likely to be wrong. I'll fix that later. Change-Id: I8efc33e54fca1fe3636006fe8616ae20aa8c211b Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -88,7 +88,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Project *> m_projects;
|
QList<Project *> m_projects;
|
||||||
Project *m_startupProject;
|
|
||||||
QStringList m_failedProjects;
|
QStringList m_failedProjects;
|
||||||
QMap<QString, QStringList> m_depMap;
|
QMap<QString, QStringList> m_depMap;
|
||||||
|
|
||||||
@@ -105,7 +104,6 @@ using namespace ProjectExplorer;
|
|||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
SessionFile::SessionFile()
|
SessionFile::SessionFile()
|
||||||
: m_startupProject(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +123,8 @@ SessionManager::SessionManager(QObject *parent)
|
|||||||
m_file(new SessionFile),
|
m_file(new SessionFile),
|
||||||
m_sessionNode(new SessionNode(this)),
|
m_sessionNode(new SessionNode(this)),
|
||||||
m_sessionName(QLatin1String("default")),
|
m_sessionName(QLatin1String("default")),
|
||||||
m_virginSession(true)
|
m_virginSession(true),
|
||||||
|
m_startupProject(0)
|
||||||
{
|
{
|
||||||
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||||
this, SLOT(saveActiveMode(Core::IMode*)));
|
this, SLOT(saveActiveMode(Core::IMode*)));
|
||||||
@@ -277,16 +276,16 @@ void SessionManager::setStartupProject(Project *startupProject)
|
|||||||
Q_ASSERT(m_file->m_projects.contains(startupProject));
|
Q_ASSERT(m_file->m_projects.contains(startupProject));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_file->m_startupProject == startupProject)
|
if (m_startupProject == startupProject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_file->m_startupProject = startupProject;
|
m_startupProject = startupProject;
|
||||||
emit startupProjectChanged(startupProject);
|
emit startupProjectChanged(startupProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
Project *SessionManager::startupProject() const
|
Project *SessionManager::startupProject() const
|
||||||
{
|
{
|
||||||
return m_file->m_startupProject;
|
return m_startupProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::addProject(Project *project)
|
void SessionManager::addProject(Project *project)
|
||||||
@@ -353,6 +352,7 @@ bool SessionManager::createImpl(const QString &fileName)
|
|||||||
emit aboutToUnloadSession();
|
emit aboutToUnloadSession();
|
||||||
delete m_file;
|
delete m_file;
|
||||||
m_file = new SessionFile;
|
m_file = new SessionFile;
|
||||||
|
m_startupProject = 0;
|
||||||
const QString &sessionName = sessionNameFromFileName(fileName);
|
const QString &sessionName = sessionNameFromFileName(fileName);
|
||||||
emit aboutToLoadSession(sessionName);
|
emit aboutToLoadSession(sessionName);
|
||||||
m_sessionName = sessionName;
|
m_sessionName = sessionName;
|
||||||
@@ -396,6 +396,7 @@ bool SessionManager::loadImpl(const QString &fileName)
|
|||||||
emit aboutToUnloadSession();
|
emit aboutToUnloadSession();
|
||||||
delete m_file;
|
delete m_file;
|
||||||
m_file = new SessionFile;
|
m_file = new SessionFile;
|
||||||
|
m_startupProject = 0;
|
||||||
const QString &sessionName = sessionNameFromFileName(fileName);
|
const QString &sessionName = sessionNameFromFileName(fileName);
|
||||||
emit aboutToLoadSession(sessionName);
|
emit aboutToLoadSession(sessionName);
|
||||||
m_sessionName = sessionName;
|
m_sessionName = sessionName;
|
||||||
@@ -463,11 +464,11 @@ bool SessionManager::loadImpl(const QString &fileName)
|
|||||||
const QString startupProjectPath = startupProject;
|
const QString startupProjectPath = startupProject;
|
||||||
foreach (Project *pro, m_file->m_projects) {
|
foreach (Project *pro, m_file->m_projects) {
|
||||||
if (QDir::cleanPath(pro->file()->fileName()) == startupProjectPath) {
|
if (QDir::cleanPath(pro->file()->fileName()) == startupProjectPath) {
|
||||||
m_file->m_startupProject = pro;
|
m_startupProject = pro;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_file->m_startupProject)
|
if (!m_startupProject)
|
||||||
qWarning() << "Could not find startup project" << startupProjectPath;
|
qWarning() << "Could not find startup project" << startupProjectPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +486,7 @@ bool SessionManager::loadImpl(const QString &fileName)
|
|||||||
|
|
||||||
// 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
|
||||||
emit startupProjectChanged(m_file->m_startupProject);
|
emit startupProjectChanged(m_startupProject);
|
||||||
|
|
||||||
QStringList failedProjects = m_file->m_failedProjects;
|
QStringList failedProjects = m_file->m_failedProjects;
|
||||||
if (!failedProjects.isEmpty()) {
|
if (!failedProjects.isEmpty()) {
|
||||||
@@ -532,8 +533,8 @@ bool SessionManager::save()
|
|||||||
PersistentSettingsWriter writer;
|
PersistentSettingsWriter writer;
|
||||||
|
|
||||||
// save the startup project
|
// save the startup project
|
||||||
if (m_file->m_startupProject) {
|
if (m_startupProject) {
|
||||||
writer.saveValue(QLatin1String("StartupProject"), m_file->m_startupProject->file()->fileName());
|
writer.saveValue(QLatin1String("StartupProject"), m_startupProject->file()->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList projectFiles;
|
QStringList projectFiles;
|
||||||
@@ -826,7 +827,7 @@ void SessionManager::removeProjects(QList<Project *> remove)
|
|||||||
pro->saveSettings();
|
pro->saveSettings();
|
||||||
m_file->m_projects.removeOne(pro);
|
m_file->m_projects.removeOne(pro);
|
||||||
|
|
||||||
if (pro == m_file->m_startupProject)
|
if (pro == m_startupProject)
|
||||||
setStartupProject(0);
|
setStartupProject(0);
|
||||||
|
|
||||||
disconnect(pro, SIGNAL(fileListChanged()),
|
disconnect(pro, SIGNAL(fileListChanged()),
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ private:
|
|||||||
|
|
||||||
mutable QHash<Project *, QStringList> m_projectFileCache;
|
mutable QHash<Project *, QStringList> m_projectFileCache;
|
||||||
QTimer *m_autoSaveSessionTimer;
|
QTimer *m_autoSaveSessionTimer;
|
||||||
|
|
||||||
|
Project *m_startupProject;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
Reference in New Issue
Block a user