summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2023-02-07 11:55:49 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-24 04:47:42 +0000
commitba48c52625b5a6ff9acf07754e66cca20b391762 (patch)
treea7681cd4b157a47d92913c74947081826fef9c0e
parent53a25dbdb7ac4031510b02171b8a30a59805f9ab (diff)
qdoc: Config: Streamline working directory handling
Let Config::[push|pop]WorkingDir() manage the working directory in addition to storing it, remove the unused return value from the latter, and add a Q_ASSERT to guard against popping an empty stack. Change-Id: I4983658f9d21eebaeb447b507694b0da1145e48c Reviewed-by: Luca Di Sera <luca.disera@qt.io> (cherry picked from commit 347cdb15fd4d938c866a77ecf458bbee2723ac91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qdoc/config.cpp26
-rw-r--r--src/qdoc/config.h2
2 files changed, 14 insertions, 14 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 4fef9529a..f398faa35 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -1083,9 +1083,7 @@ QStringList Config::loadMaster(const QString &fileName)
void Config::load(Location location, const QString &fileName)
{
QFileInfo fileInfo(fileName);
- QString path = fileInfo.canonicalPath();
- pushWorkingDir(path);
- QDir::setCurrent(path);
+ pushWorkingDir(fileInfo.canonicalPath());
static const QRegularExpression keySyntax(QRegularExpression::anchoredPattern(QLatin1String("\\w+(?:\\.\\w+)*")));
#define SKIP_CHAR() \
@@ -1200,7 +1198,7 @@ void Config::load(Location location, const QString &fileName)
/*
Here is the recursive call.
*/
- load(location, QFileInfo(QDir(path), includeFile).filePath());
+ load(location, QFileInfo(QDir(m_workingDirs.top()), includeFile).filePath());
} else {
/*
It wasn't an include statement, so it's something else.
@@ -1318,8 +1316,7 @@ void Config::load(Location location, const QString &fileName)
}
}
popWorkingDir();
- if (!m_workingDirs.isEmpty())
- QDir::setCurrent(m_workingDirs.top());
+
#undef SKIP_CHAR
#undef SKIP_SPACES
#undef PUT_CHAR
@@ -1376,23 +1373,26 @@ QStringList Config::getFilesHere(const QString &uncleanDir, const QString &nameF
}
/*!
- Push \a dir onto the stack of working directories.
+ Set \a dir as the working directory and push it onto the
+ stack of working directories.
*/
void Config::pushWorkingDir(const QString &dir)
{
m_workingDirs.push(dir);
+ QDir::setCurrent(dir);
}
/*!
- If the stack of working directories is not empty, pop the
- top entry and return it. Otherwise return an empty string.
+ Pop the top entry from the stack of working directories.
+ Set the working directory to the next one on the stack,
+ if one exists.
*/
-QString Config::popWorkingDir()
+void Config::popWorkingDir()
{
+ Q_ASSERT(!m_workingDirs.isEmpty());
+ m_workingDirs.pop();
if (!m_workingDirs.isEmpty())
- return m_workingDirs.pop();
-
- return QString();
+ QDir::setCurrent(m_workingDirs.top());
}
QT_END_NAMESPACE
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 58413ae62..ac13cb3dd 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -163,7 +163,7 @@ public:
const QString &targetDirPath);
static int numParams(const QString &value);
static void pushWorkingDir(const QString &dir);
- static QString popWorkingDir();
+ static void popWorkingDir();
static const QString dot;