qdoc: ASSERT failure while writing index file

An attempt was made to write an XML attribute after the
atart tag had been closed. This has been fixed by moving
some code around.

Change-Id: I279d91c345f4217dab8fc47faabe3350258d9ece
Task-number: Qt QTBUG-40039
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
This commit is contained in:
Martin Smith 2014-07-03 15:12:44 +02:00
parent 9150563940
commit 391b2accd8

View File

@ -1070,6 +1070,25 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
writer.writeAttribute("type", functionNode->returnType());
if (!brief.isEmpty())
writer.writeAttribute("brief", brief);
/*
Note: The "signature" attribute is written to the
index file, but it is not read back in. Is that ok?
*/
QString signature = functionNode->signature();
if (functionNode->isConst())
signature += " const";
writer.writeAttribute("signature", signature);
for (int i = 0; i < functionNode->parameters().size(); ++i) {
Parameter parameter = functionNode->parameters()[i];
writer.writeStartElement("parameter");
writer.writeAttribute("left", parameter.leftType());
writer.writeAttribute("right", parameter.rightType());
writer.writeAttribute("name", parameter.name());
writer.writeAttribute("default", parameter.defaultValue());
writer.writeEndElement(); // parameter
}
}
break;
case Node::QmlProperty:
@ -1137,6 +1156,28 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
writer.writeAttribute("brief", brief);
}
break;
case Node::Enum:
{
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
if (enumNode->flagsType()) {
writer.writeAttribute("typedef",enumNode->flagsType()->fullDocumentName());
}
foreach (const EnumItem& item, enumNode->items()) {
writer.writeStartElement("value");
writer.writeAttribute("name", item.name());
writer.writeAttribute("value", item.value());
writer.writeEndElement(); // value
}
}
break;
case Node::Typedef:
{
const TypedefNode* typedefNode = static_cast<const TypedefNode*>(node);
if (typedefNode->associatedEnum()) {
writer.writeAttribute("enum",typedefNode->associatedEnum()->fullDocumentName());
}
}
break;
default:
break;
}
@ -1198,45 +1239,6 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
}
}
}
else if (node->type() == Node::Function) {
const FunctionNode* functionNode = static_cast<const FunctionNode*>(node);
/*
Note: The "signature" attribute is written to the
index file, but it is not read back in. Is that ok?
*/
QString signature = functionNode->signature();
if (functionNode->isConst())
signature += " const";
writer.writeAttribute("signature", signature);
for (int i = 0; i < functionNode->parameters().size(); ++i) {
Parameter parameter = functionNode->parameters()[i];
writer.writeStartElement("parameter");
writer.writeAttribute("left", parameter.leftType());
writer.writeAttribute("right", parameter.rightType());
writer.writeAttribute("name", parameter.name());
writer.writeAttribute("default", parameter.defaultValue());
writer.writeEndElement(); // parameter
}
}
else if (node->type() == Node::Enum) {
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
if (enumNode->flagsType()) {
writer.writeAttribute("typedef",enumNode->flagsType()->fullDocumentName());
}
foreach (const EnumItem& item, enumNode->items()) {
writer.writeStartElement("value");
writer.writeAttribute("name", item.name());
writer.writeAttribute("value", item.value());
writer.writeEndElement(); // value
}
}
else if (node->type() == Node::Typedef) {
const TypedefNode* typedefNode = static_cast<const TypedefNode*>(node);
if (typedefNode->associatedEnum()) {
writer.writeAttribute("enum",typedefNode->associatedEnum()->fullDocumentName());
}
}
return true;
}