From ccdbf30b6ac9180ead6fc22c858b6fac112d493c Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 3 Jan 2020 23:10:47 +0100 Subject: qdoc: Make Config a singleton There is no need to pass a pointer to Config throughout the API; the only instance of it is created in main() so we can turn it into a singleton. Having access to Config without API changes makes implementation of configurable features easier. Change-Id: Ida47e067865082dfe036a7a97f7f1ffc736db346 Reviewed-by: Paul Wicking --- src/qdoc/doc.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/qdoc/doc.cpp') diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp index 89748b0ad..1720fbaeb 100644 --- a/src/qdoc/doc.cpp +++ b/src/qdoc/doc.cpp @@ -1567,7 +1567,7 @@ void DocParser::include(const QString &fileName, const QString &identifier) location().fatal(tr("Too many nested '\\%1's").arg(cmdName(CMD_INCLUDE))); QString userFriendlyFilePath; - QString filePath = Doc::config()->getIncludeFilePath(fileName); + QString filePath = Config::instance().getIncludeFilePath(fileName); if (filePath.isEmpty()) { location().warning(tr("Cannot find qdoc include file '%1'").arg(fileName)); } else { @@ -3011,10 +3011,9 @@ const QStringMultiMap &Doc::metaTagMap() const return priv && priv->extra ? priv->extra->metaMap_ : *null_QStringMultiMap(); } -const Config *Doc::config_ = nullptr; - -void Doc::initialize(const Config &config) +void Doc::initialize() { + Config &config = Config::instance(); DocParser::tabSize = config.getInt(CONFIG_TABSIZE); DocParser::exampleFiles = config.getCanonicalPathList(CONFIG_EXAMPLES); DocParser::exampleDirs = config.getCanonicalPathList(CONFIG_EXAMPLEDIRS); @@ -3024,7 +3023,6 @@ void Doc::initialize(const Config &config) QmlTypeNode::qmlOnly = config.getBool(CONFIG_QMLONLY); QStringMap reverseAliasMap; - config_ = &config; for (const auto &a : config.subVars(CONFIG_ALIAS)) { QString alias = config.getString(CONFIG_ALIAS + Config::dot + a); -- cgit v1.2.1