Commit e524f524 authored by dt's avatar dt
Browse files

Allow restoreSettings() to fail,

E.g. cmake pops up a wizard then, the running of cmake can fail though.
Now you don't end i[ with a empty project then. The error reporting in
that case is not yet optimal.
parent 5a8b61b2
......@@ -163,7 +163,7 @@ QString CMakeProject::sourceDirectory() const
return QFileInfo(m_fileName).absolutePath();
}
void CMakeProject::parseCMakeLists()
bool CMakeProject::parseCMakeLists()
{
// Find cbp file
QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration()));
......@@ -289,7 +289,9 @@ void CMakeProject::parseCMakeLists()
qDebug()<<"Parsing failed";
delete m_toolChain;
m_toolChain = 0;
return false;
}
return true;
}
QString CMakeProject::buildParser(const QString &buildConfiguration) const
......@@ -555,7 +557,7 @@ MakeStep *CMakeProject::makeStep() const
}
void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
Project::restoreSettingsImpl(reader);
bool hasUserFile = !buildConfigurations().isEmpty();
......@@ -612,7 +614,9 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
setValue(activeBuildConfiguration(), "msvcVersion", copw.msvcVersion());
}
}
parseCMakeLists(); // Gets the directory from the active buildconfiguration
bool result = parseCMakeLists(); // Gets the directory from the active buildconfiguration
if (!result)
return false;
m_watcher = new ProjectExplorer::FileWatcher(this);
connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString)));
......@@ -620,6 +624,7 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
connect(this, SIGNAL(activeBuildConfigurationChanged()),
this, SLOT(slotActiveBuildConfiguration()));
return true;
}
CMakeTarget CMakeProject::targetForTitle(const QString &title)
......
......@@ -110,7 +110,7 @@ public:
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
// called by CMakeBuildSettingsWidget
void changeBuildDirectory(const QString &buildConfiguration, const QString &newBuildDirectory);
......@@ -120,7 +120,7 @@ private slots:
void slotActiveBuildConfiguration();
private:
void parseCMakeLists();
bool parseCMakeLists();
void updateToolChain(const QString &compiler);
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
......
......@@ -468,7 +468,7 @@ GenericMakeStep *GenericProject::makeStep() const
return 0;
}
void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
Project::restoreSettingsImpl(reader);
......@@ -500,6 +500,7 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
setIncludePaths(allIncludePaths());
refresh(Everything);
return true;
}
void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
......
......@@ -121,7 +121,7 @@ public Q_SLOTS:
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
private:
void parseProject(RefreshOptions options);
......
......@@ -179,17 +179,19 @@ void Project::saveSettings()
writer.save(file()->fileName() + QLatin1String(".user"), "QtCreatorProject");
}
void Project::restoreSettings()
bool Project::restoreSettings()
{
PersistentSettingsReader reader;
reader.load(file()->fileName() + QLatin1String(".user"));
restoreSettingsImpl(reader);
if (!restoreSettingsImpl(reader))
return false;
if (m_activeBuildConfiguration.isEmpty() && !m_buildConfigurations.isEmpty())
setActiveBuildConfiguration(m_buildConfigurations.at(0));
if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty())
setActiveRunConfiguration(m_runConfigurations.at(0));
return true;
}
QList<BuildStepConfigWidget*> Project::subConfigWidgets()
......@@ -276,7 +278,7 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
writer.saveValue("defaultFileEncoding", m_editorConfiguration->defaultTextCodec()->name());
}
void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
{
m_activeBuildConfiguration = reader.restoreValue("activebuildconfiguration").toString();
......@@ -383,6 +385,7 @@ void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty())
setActiveRunConfiguration(m_runConfigurations.at(0));
return true;
}
void Project::setValue(const QString &name, const QVariant & value)
......
......@@ -124,7 +124,7 @@ public:
virtual QString buildDirectory(const QString &buildConfiguration) const = 0;
void saveSettings();
void restoreSettings();
bool restoreSettings();
virtual BuildStepConfigWidget *createConfigWidget() = 0;
virtual QList<BuildStepConfigWidget*> subConfigWidgets();
......@@ -173,7 +173,7 @@ protected:
* probably add some default build and run settings to the project so that
* it can be build and run.
*/
virtual void restoreSettingsImpl(PersistentSettingsReader &reader);
virtual bool restoreSettingsImpl(PersistentSettingsReader &reader);
private:
Internal::BuildConfiguration *getBuildConfiguration(const QString & name) const;
......
......@@ -939,16 +939,24 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
return QList<Project *>();
}
foreach (Project *pro, openedPro) {
QList<Project *>::iterator it, end;
end = openedPro.end();
for (it = openedPro.begin(); it != end; ) {
if (debug)
qDebug()<<"restoring settings for "<<pro->file()->fileName();
pro->restoreSettings();
connect(pro, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
qDebug()<<"restoring settings for "<<(*it)->file()->fileName();
if ((*it)->restoreSettings()) {
connect(*it, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
++it;
} else {
delete *it;
it = openedPro.erase(it);
}
}
m_session->addProjects(openedPro);
// Make sure we always have a current project / node
if (!m_currentProject)
if (!m_currentProject && !openedPro.isEmpty())
setCurrentNode(openedPro.first()->rootProjectNode());
updateActions();
......
......@@ -239,7 +239,7 @@ QmlMakeStep *QmlProject::makeStep() const
return 0;
}
void QmlProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
bool QmlProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
Project::restoreSettingsImpl(reader);
......@@ -254,6 +254,7 @@ void QmlProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &
}
refresh(Everything);
return true;
}
void QmlProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
......
......@@ -93,7 +93,7 @@ public:
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
private:
void parseProject(RefreshOptions options);
......
......@@ -290,7 +290,7 @@ void Qt4Project::updateFileList()
}
}
void Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
bool Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
{
Project::restoreSettingsImpl(settingsReader);
......@@ -350,7 +350,7 @@ void Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
connect(m_nodesWatcher, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)),
this, SLOT(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)));
return true;
}
void Qt4Project::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
......
......@@ -219,7 +219,7 @@ private slots:
void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
protected:
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &settingsReader);
virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &settingsReader);
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
private:
......
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