From b34f81532688f6b3809e17a9bbd98f72015fe915 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 27 Mar 2018 12:36:59 +0200 Subject: qdoc: Distinguish between undefined and defined-as-empty config vars Make Config::getString() return an empty string for variables that are defined as empty, while continuing to return a null string for undefined ones. Use a defined-as-empty 'moduleheader' variable: moduleheader = to mark a documentation project that doesn't need a precompiled header to be built. Change-Id: I2ccb631c73a1b91dc35955e5f21648db88915064 Reviewed-by: Martin Smith --- src/qdoc/clangcodeparser.cpp | 2 +- src/qdoc/config.cpp | 7 ++++++- src/qdoc/main.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 77055ca9f..ec145c736 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1176,7 +1176,7 @@ void ClangCodeParser::getMoreArgs() */ void ClangCodeParser::buildPCH() { - if (!pchFileDir_) { + if (!pchFileDir_ && !moduleHeader().isEmpty()) { pchFileDir_.reset(new QTemporaryDir(QDir::tempPath() + QLatin1String("/qdoc_pch"))); if (pchFileDir_->isValid()) { //const QByteArray module = qdb_->primaryTreeRoot()->tree()->camelCaseModuleName().toUtf8(); diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index de7f23ce6..64c8786f6 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -397,12 +397,17 @@ QSet Config::getOutputFormats() const If \a var is not contained in the location map it returns \a defaultString. + + \note By default, \a defaultString is a null string. If \a var + is found but contains an empty string, that is returned instead. + This allows determining whether a configuration variable is + undefined (null string) or defined as empty (empty string). */ QString Config::getString(const QString& var, const QString& defaultString) const { QList configVars = configVars_.values(var); if (!configVars.empty()) { - QString value; + QString value(""); int i = configVars.size() - 1; while (i >= 0) { const ConfigVar& cv = configVars[i]; diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index 79cde7950..563915d49 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -366,7 +366,7 @@ static void processQdocconfFile(const QString &fileName) qdb->newPrimaryTree(project); else qdb->setPrimaryTree(project); - if (!moduleHeader.isEmpty()) + if (!moduleHeader.isNull()) clangParser_->setModuleHeader(moduleHeader); else clangParser_->setModuleHeader(project); -- cgit v1.2.1