diff options
author | Topi Reinio <topi.reinio@digia.com> | 2015-02-17 13:22:53 +0100 |
---|---|---|
committer | Topi Reiniƶ <topi.reinio@digia.com> | 2015-02-27 11:41:05 +0000 |
commit | 4fd8513475222ee0afb6f18ec90ba384ffb03bc4 (patch) | |
tree | 17769faeed33cfd74b9b444863c27bd5ff59df3b /src/tools | |
parent | 3146dadb42cb36aff83a62e831b8b4f4dc1562a7 (diff) |
qdoc: Improve handling of current working directory
When qdoc reads (potentially nested) documentation files, it sets
the current working directory to the path of the currently read
file to make relative paths work for include statements and
config variables. This works as long as there's only one top-level
.qdocconf file.
This change fixes problems with handling the CWD to enable
relative paths also when we have multiple top-level .qdocconf
files, as is the case when running qdoc in single-exec mode.
Change-Id: I03a7ec5af93d54070ea29f90ea2ba29c57028781
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/qdoc/config.cpp | 10 | ||||
-rw-r--r-- | src/tools/qdoc/main.cpp | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp index 5ab3cb0d7d..e3b2f0325d 100644 --- a/src/tools/qdoc/config.cpp +++ b/src/tools/qdoc/config.cpp @@ -912,8 +912,10 @@ QStringList Config::loadMaster(const QString& fileName) */ void Config::load(Location location, const QString& fileName) { - pushWorkingDir(QFileInfo(fileName).path()); - QDir::setCurrent(QFileInfo(fileName).path()); + QFileInfo fileInfo(fileName); + QString path = fileInfo.canonicalPath(); + pushWorkingDir(path); + QDir::setCurrent(path); QRegExp keySyntax(QLatin1String("\\w+(?:\\.\\w+)*")); #define SKIP_CHAR() \ @@ -935,7 +937,7 @@ void Config::load(Location location, const QString& fileName) if (location.depth() > 16) location.fatal(tr("Too many nested includes")); - QFile fin(fileName); + QFile fin(fileInfo.fileName()); if (!fin.open(QFile::ReadOnly | QFile::Text)) { if (!Config::installDir.isEmpty()) { int prefix = location.filePath().length() - location.fileName().length(); @@ -1030,7 +1032,7 @@ void Config::load(Location location, const QString& fileName) /* Here is the recursive call. */ - load(location, QFileInfo(QFileInfo(fileName).dir(), includeFile).filePath()); + load(location, QFileInfo(QDir(path), includeFile).filePath()); } else { /* diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index 74d706efe1..4a99ec39de 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -227,6 +227,8 @@ static void processQdocconfFile(const QString &fileName) config.setStringList(CONFIG_AUTOLINKERRORS, QStringList(autolinkErrors ? "true" : "false")); config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false")); + prevCurrentDir = QDir::currentPath(); + /* With the default configuration values in place, load the qdoc configuration file. Note that the configuration @@ -236,7 +238,6 @@ static void processQdocconfFile(const QString &fileName) in the file being processed, mainly for error reporting purposes. */ - currentDir = QFileInfo(fileName).path(); Location::initialize(config); config.load(fileName); QString project = config.getString(CONFIG_PROJECT); @@ -248,7 +249,6 @@ static void processQdocconfFile(const QString &fileName) config.setStringList(CONFIG_DEFINES,defs); Location::terminate(); - prevCurrentDir = QDir::currentPath(); currentDir = QFileInfo(fileName).path(); if (!currentDir.isEmpty()) QDir::setCurrent(currentDir); |