summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@theqtcompany.com>2015-11-24 11:50:52 +0100
committerTopi Reiniƶ <topi.reinio@theqtcompany.com>2015-11-24 11:45:05 +0000
commiteb002cf0f5a8f3b98de1317575eb77e3380797e5 (patch)
treee9a291da2002375588f79f0907acd17e909a736d
parent06dc01046aaaaa9f4d99c8e6664398f1195b4210 (diff)
downloadqttools-eb002cf0f5a8f3b98de1317575eb77e3380797e5.tar.gz
qdoc: Fix crash with multiple macro parameters
When the number of parameters expected by a macro definition does not match what's passed to the macro invocation, store the number of parameters read so far. This prevents a crash by out-of-range index reference. Also, improve the documentation on macro parameters. Change-Id: I75716f5b53f394664bb509c96aa4b53b4efba222 Task-number: QTBUG-49608 Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
-rw-r--r--src/qdoc/doc.cpp2
-rw-r--r--src/qdoc/doc/qdoc-manual-qdocconf.qdoc13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index 4ed589454..cfe28ab9f 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -2162,6 +2162,7 @@ void DocParser::expandMacro(const QString &name,
location().warning(tr("Macro '\\%1' invoked with too few"
" arguments (expected %2, got %3)")
.arg(name).arg(numParams).arg(i));
+ numParams = i;
break;
}
}
@@ -2204,6 +2205,7 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def,
location().warning(tr("Macro '\\%1' invoked with too few"
" arguments (expected %2, got %3)")
.arg(name).arg(numParams).arg(i));
+ numParams = i;
break;
}
}
diff --git a/src/qdoc/doc/qdoc-manual-qdocconf.qdoc b/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
index 69980c1e1..045be3b33 100644
--- a/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
+++ b/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
@@ -737,7 +737,7 @@
A macro can also take up to seven parameters:
\badcode
- macro.hello = "Hello \1!"
+ macro.hello = "Hello \1!"
\endcode
Parameters are passed to macros the same way as to other commands:
@@ -746,6 +746,17 @@
\hello World
\endcode
+ When using more than one parameter, or when an argument
+ contains whitespace, enclose each argument in braces:
+
+ \badcode
+ macro.verinfo = "\1 (version \2)"
+ \endcode
+
+ \badcode
+ \verinfo {QFooBar} {1.0 beta}
+ \endcode
+
See also \l {alias-variable} {alias}.
\target manifestmeta-variable