diff options
author | Martin Smith <martin.smith@digia.com> | 2013-03-07 10:23:57 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-07 11:27:49 +0100 |
commit | a19c22ebf8775f73b840f52b7e03869166ca0dab (patch) | |
tree | e8474cb6f5f45621a2089f118ff8df3c791e121a /src/tools | |
parent | 0e8520d18f700c42ffff12e111ee4fc25caac55a (diff) |
qdoc: Initialize an uninitialized variable
qdoc already ignores QML signal handler comments
and does not report errors for missing QML signal
handler documentation. but the test case for this
bug revealed a separate bug. The test case contains
no import statements, which, technically is legal
but probably won't happen. Still, qdoc failed to
generate output for the test case QML file because
it didn't contain an import statement before the
first qdoc comment. This was caused by an
uninitialized variable, which has now been fixed.
Task-number: QTBUG-30043
Change-Id: Iafa2087b85a6c9e354b2be86c779bbd191181218
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/qdoc/qmlvisitor.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp index 6d44b99af7..ffe1afe28b 100644 --- a/src/tools/qdoc/qmlvisitor.cpp +++ b/src/tools/qdoc/qmlvisitor.cpp @@ -88,6 +88,7 @@ QmlDocVisitor::QmlDocVisitor(const QString &filePath, QSet<QString> &topics) : nestingLevel(0) { + lastEndOffset = 0; this->filePath = filePath; this->name = QFileInfo(filePath).baseName(); document = code; @@ -117,21 +118,21 @@ QQmlJS::AST::SourceLocation QmlDocVisitor::precedingComment(quint32 offset) cons QQmlJS::AST::SourceLocation loc = it.previous(); - if (loc.begin() <= lastEndOffset) + if (loc.begin() <= lastEndOffset) { // Return if we reach the end of the preceding structure. break; - - else if (usedComments.contains(loc.begin())) + } + else if (usedComments.contains(loc.begin())) { // Return if we encounter a previously used comment. break; - + } else if (loc.begin() > lastEndOffset && loc.end() < offset) { - // Only examine multiline comments in order to avoid snippet markers. if (document.at(loc.offset - 1) == QLatin1Char('*')) { QString comment = document.mid(loc.offset, loc.length); - if (comment.startsWith(QLatin1Char('!')) || comment.startsWith(QLatin1Char('*'))) + if (comment.startsWith(QLatin1Char('!')) || comment.startsWith(QLatin1Char('*'))) { return loc; + } } } } @@ -165,8 +166,9 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::AST::SourceLocation location, Nod node->setDoc(doc); applyMetacommands(loc, node, doc); usedComments.insert(loc.offset); - if (doc.isEmpty()) + if (doc.isEmpty()) { return false; + } return true; } Location codeLoc(filePath); |