forked from qt-creator/qt-creator
CMake: Break loop in error handling
Block access to the BuildDirManager while one of its errors is processed. This prevents more errors being raised as part of error handling, which can trigger a loop. Task-number: QTCREATORBUG-17869 Change-Id: Ic6f8d9a3c3b4e63f27260c40f27ab09d20b62b3e Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -75,7 +75,7 @@ const Utils::FileName BuildDirManager::workDirectory() const
|
|||||||
if (!m_tempDir) {
|
if (!m_tempDir) {
|
||||||
m_tempDir.reset(new Utils::TemporaryDirectory("qtc-cmake-XXXXXXXX"));
|
m_tempDir.reset(new Utils::TemporaryDirectory("qtc-cmake-XXXXXXXX"));
|
||||||
if (!m_tempDir->isValid())
|
if (!m_tempDir->isValid())
|
||||||
emit errorOccured(tr("Failed to create temporary directory \"%1\".").arg(m_tempDir->path()));
|
emitErrorOccured(tr("Failed to create temporary directory \"%1\".").arg(m_tempDir->path()));
|
||||||
}
|
}
|
||||||
return Utils::FileName::fromString(m_tempDir->path());
|
return Utils::FileName::fromString(m_tempDir->path());
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,13 @@ void BuildDirManager::emitDataAvailable()
|
|||||||
emit dataAvailable();
|
emit dataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuildDirManager::emitErrorOccured(const QString &message) const
|
||||||
|
{
|
||||||
|
m_isHandlingError = true;
|
||||||
|
emit errorOccured(message);
|
||||||
|
m_isHandlingError = false;
|
||||||
|
}
|
||||||
|
|
||||||
void BuildDirManager::updateReaderType(std::function<void()> todo)
|
void BuildDirManager::updateReaderType(std::function<void()> todo)
|
||||||
{
|
{
|
||||||
BuildDirReader::Parameters p(m_buildConfiguration);
|
BuildDirReader::Parameters p(m_buildConfiguration);
|
||||||
@@ -98,7 +105,7 @@ void BuildDirManager::updateReaderType(std::function<void()> todo)
|
|||||||
connect(m_reader.get(), &BuildDirReader::dataAvailable,
|
connect(m_reader.get(), &BuildDirReader::dataAvailable,
|
||||||
this, &BuildDirManager::emitDataAvailable);
|
this, &BuildDirManager::emitDataAvailable);
|
||||||
connect(m_reader.get(), &BuildDirReader::errorOccured,
|
connect(m_reader.get(), &BuildDirReader::errorOccured,
|
||||||
this, &BuildDirManager::errorOccured);
|
this, &BuildDirManager::emitErrorOccured);
|
||||||
connect(m_reader.get(), &BuildDirReader::dirty, this, &BuildDirManager::becameDirty);
|
connect(m_reader.get(), &BuildDirReader::dirty, this, &BuildDirManager::becameDirty);
|
||||||
}
|
}
|
||||||
m_reader->setParameters(p);
|
m_reader->setParameters(p);
|
||||||
@@ -216,6 +223,8 @@ void BuildDirManager::becameDirty()
|
|||||||
|
|
||||||
void BuildDirManager::forceReparse()
|
void BuildDirManager::forceReparse()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return);
|
||||||
|
|
||||||
if (m_buildConfiguration->target()->activeBuildConfiguration() != m_buildConfiguration)
|
if (m_buildConfiguration->target()->activeBuildConfiguration() != m_buildConfiguration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -228,6 +237,8 @@ void BuildDirManager::forceReparse()
|
|||||||
|
|
||||||
void BuildDirManager::resetData()
|
void BuildDirManager::resetData()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return);
|
||||||
|
|
||||||
if (m_reader)
|
if (m_reader)
|
||||||
m_reader->resetData();
|
m_reader->resetData();
|
||||||
|
|
||||||
@@ -259,6 +270,7 @@ bool BuildDirManager::persistCMakeState()
|
|||||||
|
|
||||||
void BuildDirManager::generateProjectTree(CMakeProjectNode *root, const QList<const FileNode *> &allFiles)
|
void BuildDirManager::generateProjectTree(CMakeProjectNode *root, const QList<const FileNode *> &allFiles)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return);
|
||||||
QTC_ASSERT(m_reader, return);
|
QTC_ASSERT(m_reader, return);
|
||||||
|
|
||||||
const Utils::FileName projectFile = m_buildConfiguration->target()->project()->projectFilePath();
|
const Utils::FileName projectFile = m_buildConfiguration->target()->project()->projectFilePath();
|
||||||
@@ -272,6 +284,7 @@ void BuildDirManager::generateProjectTree(CMakeProjectNode *root, const QList<co
|
|||||||
|
|
||||||
void BuildDirManager::updateCodeModel(CppTools::RawProjectParts &rpps)
|
void BuildDirManager::updateCodeModel(CppTools::RawProjectParts &rpps)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return);
|
||||||
QTC_ASSERT(m_reader, return);
|
QTC_ASSERT(m_reader, return);
|
||||||
return m_reader->updateCodeModel(rpps);
|
return m_reader->updateCodeModel(rpps);
|
||||||
}
|
}
|
||||||
@@ -283,6 +296,8 @@ void BuildDirManager::parse()
|
|||||||
|
|
||||||
void BuildDirManager::clearCache()
|
void BuildDirManager::clearCache()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return);
|
||||||
|
|
||||||
auto cmakeCache = Utils::FileName(workDirectory()).appendPath(QLatin1String("CMakeCache.txt"));
|
auto cmakeCache = Utils::FileName(workDirectory()).appendPath(QLatin1String("CMakeCache.txt"));
|
||||||
auto cmakeFiles = Utils::FileName(workDirectory()).appendPath(QLatin1String("CMakeFiles"));
|
auto cmakeFiles = Utils::FileName(workDirectory()).appendPath(QLatin1String("CMakeFiles"));
|
||||||
|
|
||||||
@@ -298,6 +313,8 @@ void BuildDirManager::clearCache()
|
|||||||
|
|
||||||
QList<CMakeBuildTarget> BuildDirManager::buildTargets() const
|
QList<CMakeBuildTarget> BuildDirManager::buildTargets() const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return {});
|
||||||
|
|
||||||
if (!m_reader)
|
if (!m_reader)
|
||||||
return QList<CMakeBuildTarget>();
|
return QList<CMakeBuildTarget>();
|
||||||
if (m_buildTargets.isEmpty())
|
if (m_buildTargets.isEmpty())
|
||||||
@@ -307,6 +324,8 @@ QList<CMakeBuildTarget> BuildDirManager::buildTargets() const
|
|||||||
|
|
||||||
CMakeConfig BuildDirManager::parsedConfiguration() const
|
CMakeConfig BuildDirManager::parsedConfiguration() const
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_isHandlingError, return {});
|
||||||
|
|
||||||
if (!m_reader)
|
if (!m_reader)
|
||||||
return m_cmakeCache;
|
return m_cmakeCache;
|
||||||
if (m_cmakeCache.isEmpty())
|
if (m_cmakeCache.isEmpty())
|
||||||
@@ -389,6 +408,9 @@ void BuildDirManager::checkConfiguration()
|
|||||||
|
|
||||||
void BuildDirManager::maybeForceReparse()
|
void BuildDirManager::maybeForceReparse()
|
||||||
{
|
{
|
||||||
|
if (m_isHandlingError)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!m_reader || !m_reader->hasData()) {
|
if (!m_reader || !m_reader->hasData()) {
|
||||||
forceReparse();
|
forceReparse();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void emitDataAvailable();
|
void emitDataAvailable();
|
||||||
|
void emitErrorOccured(const QString &message) const;
|
||||||
void checkConfiguration();
|
void checkConfiguration();
|
||||||
|
|
||||||
const Utils::FileName workDirectory() const;
|
const Utils::FileName workDirectory() const;
|
||||||
@@ -109,6 +110,7 @@ private:
|
|||||||
std::unique_ptr<BuildDirReader> m_reader;
|
std::unique_ptr<BuildDirReader> m_reader;
|
||||||
|
|
||||||
mutable QList<CMakeBuildTarget> m_buildTargets;
|
mutable QList<CMakeBuildTarget> m_buildTargets;
|
||||||
|
mutable bool m_isHandlingError = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user