summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2019-09-26 10:47:13 +0200
committerTopi Reinio <topi.reinio@qt.io>2019-09-27 11:33:59 +0200
commitc05f918435fab435d4492c3df24afcb872671a93 (patch)
treed97f0c80a2a8422bedfd3d48d54ee64e68f4eea2
parent0407495a027b8e662c773eafb50ab66fd4638962 (diff)
qdoc: Clear config variables before loading a new .qdocconf file
Previously, this problem was masked as the Config object was local to the processQdocconf() function in main.cpp - but now we keep that object and process multiple .qdocconf files in single-exec mode. When in single-exec mode, the previously read variables remained in the config, resulting in all kinds of unintended consequences - such as processing source directories from other documentation projects. Fixes: QTBUG-78776 Change-Id: Ic23d1cb0eacb112cc60a63cd43b4d51ff57f0583 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/config.cpp43
-rw-r--r--src/qdoc/config.h2
2 files changed, 30 insertions, 15 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 25c97af70..7b96ebdd7 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -266,13 +266,33 @@ QMap<QString, QStringList> Config::includeFilesMap_;
Config::Config(const QString &programName)
: prog(programName)
{
- loc = Location::null;
- lastLocation_ = Location::null;
- configVars_.clear();
numInstances++;
+ reset();
+}
+
+Config::~Config()
+{
+ clear();
+}
+
+/*!
+ Clears the location and internal maps for config variables.
+ */
+void Config::clear()
+{
+ loc = lastLocation_ = Location::null;
+ configVars_.clear();
includeFilesMap_.clear();
+}
+
+/*!
+ Resets the Config instance - used by load()
+ */
+void Config::reset()
+{
+ clear();
- // Default values:
+ // Default values
setStringList(CONFIG_CODEINDENT, QStringList("0"));
setStringList(CONFIG_FALSEHOODS, QStringList("0"));
setStringList(CONFIG_FILEEXTENSIONS, QStringList("*.cpp *.h *.qdoc *.qml"));
@@ -282,24 +302,17 @@ Config::Config(const QString &programName)
}
/*!
- The destructor has nothing special to do.
- */
-Config::~Config()
-{
- includeFilesMap_.clear();
-}
-
-/*!
Loads and parses the qdoc configuration file \a fileName.
- This function calls the other load() function, which does
- the loading, parsing, and processing of the configuration
- file.
+ This function first resets the Config instance, then
+ calls the other load() function, which does the loading,
+ parsing, and processing of the configuration file.
Intializes the location variables returned by location()
and lastLocation().
*/
void Config::load(const QString &fileName)
{
+ reset();
load(Location::null, fileName);
if (loc.isEmpty())
loc = Location(fileName);
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 71ad6dc3b..615387f73 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -80,6 +80,8 @@ public:
bool getDebug() const { return debug_; }
+ void clear();
+ void reset();
void load(const QString &fileName);
void setStringList(const QString &var, const QStringList &values);
void insertStringList(const QString &var, const QStringList &values);