Commit 6501b35c authored by Kevin Funk's avatar Kevin Funk

duchain: Make htmlIdentifiedType() crash-safe

Unfortunately not easy to add a regression test given the current qmljs
testing infrastructure.

BUG: 396634
FIXED-IN: 5.3.0
parent 5343c36f
......@@ -589,10 +589,24 @@ void AbstractDeclarationNavigationContext::htmlClass()
void AbstractDeclarationNavigationContext::htmlIdentifiedType(AbstractType::Ptr type, const IdentifiedType* idType)
{
Q_ASSERT(type);
Q_ASSERT(idType);
if (!type) {
qCDebug(LANGUAGE) << "null type!";
return;
}
if (!idType) {
qCDebug(LANGUAGE) << "no identified type for" << type->toString();
modifyHtml() += typeHighlight(type->toString().toHtmlEscaped());
return;
}
auto* decl = idType->declaration(topContext().data());
if (!decl) {
qCDebug(LANGUAGE) << "could not resolve declaration:" << idType->declarationId().isDirect() << idType->qualifiedIdentifier().toString() << "in top-context" << topContext()->url().str();
modifyHtml() += typeHighlight(type->toString().toHtmlEscaped());
return;
}
if( Declaration* decl = idType->declaration(topContext().data()) ) {
//Remove the last template-identifiers, because we create those directly
QualifiedIdentifier id = prettyQualifiedIdentifier(DeclarationPointer(decl));
......@@ -617,10 +631,6 @@ void AbstractDeclarationNavigationContext::htmlIdentifiedType(AbstractType::Ptr
//We leave out the * and & reference and pointer signs, those are added to the end
makeLink(id.toString() , DeclarationPointer(idType->declaration(topContext().data())), NavigationAction::NavigateDeclaration );
} else {
qCDebug(LANGUAGE) << "could not resolve declaration:" << idType->declarationId().isDirect() << idType->qualifiedIdentifier().toString() << "in top-context" << topContext()->url().str();
modifyHtml() += typeHighlight(type->toString().toHtmlEscaped());
}
}
void AbstractDeclarationNavigationContext::eventuallyMakeTypeLinks( AbstractType::Ptr type )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment