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>
This commit is contained in:
Martin Smith 2013-03-07 10:23:57 +01:00 committed by The Qt Project
parent 0e8520d18f
commit a19c22ebf8

View File

@ -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);