diff options
author | Paul Wicking <paul.wicking@qt.io> | 2023-03-10 09:57:18 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2023-03-13 13:20:35 +0100 |
commit | ea641ace22e8c2eca957470206cd20b54f7bd9a0 (patch) | |
tree | 56fc973cc4a32c9ed46f387c99af674989ec4bd9 | |
parent | 13b74294b92c5f2eede46ce5da6e20271e66d0d7 (diff) | |
download | qttools-ea641ace22e8c2eca957470206cd20b54f7bd9a0.tar.gz |
QDoc: Make global static in main local to function
Move the global static ClangCodeParser into the one function that needs
it, such that initialize/terminate behavior can be moved into ctor/dtor
where it ought to be.
Task-number: QTBUG-111686
Change-Id: I7034ba8ed302516e7d5dc36fcec1892d081f2072
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
-rw-r--r-- | src/qdoc/main.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index 1d0af6078..69a6bcc96 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -49,8 +49,6 @@ typedef std::pair<QString, QTranslator *> Translator; static QList<Translator> translators; #endif -static ClangCodeParser *clangParser_ = nullptr; - /*! Read some XML indexes containing definitions from other documentation sets. \a config contains a variable that @@ -237,6 +235,7 @@ static void processQdocconfFile(const QString &fileName) { Config &config = Config::instance(); config.setPreviousCurrentDir(QDir::currentPath()); + ClangCodeParser clangParser; /* With the default configuration values in place, load @@ -449,9 +448,9 @@ static void processQdocconfFile(const QString &fileName) const QString moduleHeader = config.getString(CONFIG_MODULEHEADER); if (!moduleHeader.isNull()) - clangParser_->setModuleHeader(moduleHeader); + clangParser.setModuleHeader(moduleHeader); else - clangParser_->setModuleHeader(project); + clangParser.setModuleHeader(project); // Retrieve the dependencies if loadIndexFiles() was not called if (config.dependModules().isEmpty()) { @@ -527,10 +526,10 @@ static void processQdocconfFile(const QString &fileName) qCDebug(lcQdoc, "Parsing header files"); for (auto it = headers.constBegin(); it != headers.constEnd(); ++it) { qCDebug(lcQdoc, "Parsing %s", qPrintable(it.key())); - clangParser_->parseHeaderFile(config.location(), it.key()); + clangParser.parseHeaderFile(config.location(), it.key()); } - clangParser_->precompileHeaders(); + clangParser.precompileHeaders(); /* Parse each source text file in the set using the appropriate parser and @@ -613,8 +612,6 @@ int main(int argc, char **argv) Create code parsers for the languages to be parsed, and create a tree for C++. */ - ClangCodeParser clangParser; - clangParser_ = &clangParser; QmlCodeParser qmlParser; PureDocParser docParser; |