From 9cef89e691877bc16637f2bcc93b935b62fa1c6f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 11 Jun 2012 18:29:54 +0200 Subject: [PATCH] make failure to load spec or cache fatal our processing is nowadays precise enough to allow for that. Change-Id: I0e5c7bb4b40f713f5b4cef26bb7d4c49170ae7ac Reviewed-by: Daniel Teske --- src/shared/proparser/qmakeevaluator.cpp | 43 ++++++++++++++----------- src/shared/proparser/qmakeevaluator.h | 4 +-- src/shared/proparser/qmakeglobals.h | 3 ++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 7a2b8be989d..6aaaa85c4b7 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -827,7 +827,7 @@ void QMakeEvaluator::visitProVariable( } } -void QMakeEvaluator::prepareProject() +bool QMakeEvaluator::prepareProject() { // ### init QMAKE_QMAKE, QMAKE_SH // ### init QMAKE_EXT_{C,H,CPP,OBJ} @@ -852,18 +852,17 @@ void QMakeEvaluator::prepareProject() #ifdef PROEVALUATOR_CUMULATIVE evaluator.m_cumulative = false; #endif - if (evaluator.evaluateFileDirect(qmake_cache, QMakeHandler::EvalConfigFile, LoadProOnly)) { - if (m_option->qmakespec.isEmpty()) - m_option->qmakespec = evaluator.first(ProString("QMAKESPEC")).toQString(); - } else { - qmake_cache.clear(); - } + if (!evaluator.evaluateFileDirect(qmake_cache, QMakeHandler::EvalConfigFile, LoadProOnly)) + return false; + if (m_option->qmakespec.isEmpty()) + m_option->qmakespec = evaluator.first(ProString("QMAKESPEC")).toQString(); } m_option->cachefile = qmake_cache; } + return true; } -void QMakeEvaluator::loadSpec() +bool QMakeEvaluator::loadSpec() { #ifdef PROEVALUATOR_CUMULATIVE m_cumulative = false; @@ -881,20 +880,16 @@ void QMakeEvaluator::loadSpec() } } m_handler->configError(fL1S("Could not find qmake configuration file")); - // Unlike in qmake, a missing config is not critical ... - qmakespec.clear(); + return false; } cool: - - if (!qmakespec.isEmpty()) { m_option->qmakespec = QDir::cleanPath(qmakespec); QString spec = m_option->qmakespec + QLatin1String("/qmake.conf"); if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) { m_handler->configError( fL1S("Could not read qmake configuration file %1").arg(spec)); - } else if (!m_option->cachefile.isEmpty()) { - evaluateFileDirect(m_option->cachefile, QMakeHandler::EvalConfigFile, LoadProOnly); + return false; } m_option->qmakespec_name = IoUtils::fileName(m_option->qmakespec).toString(); if (m_option->qmakespec_name == QLatin1String("default")) { @@ -915,7 +910,11 @@ void QMakeEvaluator::loadSpec() IoUtils::fileName(spec_org.first().toQString()).toString(); #endif } - } + if (!m_option->cachefile.isEmpty() + && !evaluateFileDirect(m_option->cachefile, QMakeHandler::EvalConfigFile, LoadProOnly)) { + return false; + } + return true; } void QMakeEvaluator::visitCmdLine(const QString &cmds) @@ -944,6 +943,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( QThreadPool::globalInstance()->releaseThread(); m_option->cond.wait(&m_option->mutex); QThreadPool::globalInstance()->reserveThread(); + if (!m_option->base_isOk) + return ReturnFalse; } else #endif if (!m_option->base_eval) { @@ -952,16 +953,22 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( locker.unlock(); #endif - prepareProject(); + bool ok = prepareProject(); - m_option->base_eval = new QMakeEvaluator(m_option, m_parser, m_handler); - m_option->base_eval->loadSpec(); + if (ok) { + m_option->base_eval = new QMakeEvaluator(m_option, m_parser, m_handler); + ok = m_option->base_eval->loadSpec(); + } #ifdef PROEVALUATOR_THREAD_SAFE locker.relock(); + m_option->base_isOk = ok; m_option->base_inProgress = false; m_option->cond.wakeAll(); #endif + + if (!ok) + return ReturnFalse; } #ifdef PROEVALUATOR_THREAD_SAFE } diff --git a/src/shared/proparser/qmakeevaluator.h b/src/shared/proparser/qmakeevaluator.h index 548edbaa550..1302556deed 100644 --- a/src/shared/proparser/qmakeevaluator.h +++ b/src/shared/proparser/qmakeevaluator.h @@ -101,8 +101,8 @@ public: static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr); void skipExpression(const ushort *&tokPtr); - void prepareProject(); - void loadSpec(); + bool prepareProject(); + bool loadSpec(); void initFrom(const QMakeEvaluator &other); void visitCmdLine(const QString &cmds); VisitReturn visitProFile(ProFile *pro, QMakeHandler::EvalFileType type, diff --git a/src/shared/proparser/qmakeglobals.h b/src/shared/proparser/qmakeglobals.h index 27162614c18..e112c07b65e 100644 --- a/src/shared/proparser/qmakeglobals.h +++ b/src/shared/proparser/qmakeglobals.h @@ -90,6 +90,9 @@ private: QMutex mutex; QWaitCondition cond; bool base_inProgress; + // The coupling of this flag to thread safety exists because for other + // use cases failure is immediately fatal anyway. + bool base_isOk; #endif QMakeEvaluator *base_eval;