ProjectExplorer: Use RAII pattern for parsing start/stop signalling

Change-Id: I13de537140f265db3e3d0ab1cd924d6897cd90c8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-06 14:46:37 +02:00
parent 8868989d5c
commit 09530d6dcc
18 changed files with 143 additions and 69 deletions

View File

@@ -31,7 +31,10 @@
using namespace AutotoolsProjectManager::Internal;
MakefileParserThread::MakefileParserThread(const QString &makefile) : m_parser(makefile)
MakefileParserThread::MakefileParserThread(const QString &makefile,
ProjectExplorer::Project::ParseGuard &&guard)
: m_parser(makefile)
, m_guard(std::move(guard))
{
connect(&m_parser, &MakefileParser::status,
this, &MakefileParserThread::status);
@@ -82,7 +85,7 @@ QStringList MakefileParserThread::cxxflags() const
bool MakefileParserThread::hasError() const
{
QMutexLocker locker(&m_mutex);
return m_hasError;
return !m_guard.isSuccess();
}
bool MakefileParserThread::isCanceled() const
@@ -104,7 +107,8 @@ void MakefileParserThread::run()
// this prevents long locks if the caller reads a value before the signal
// finished() has been emitted.
QMutexLocker locker(&m_mutex);
m_hasError = !success;
if (success)
m_guard.markAsSuccess();
m_executable = m_parser.executable();
m_sources = m_parser.sources();
m_makefiles = m_parser.makefiles();