Commit c7e47f53 authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlOutline: Don't use LookupContext due to performance issues

Creating a LookupContext can be sloooow for large projects. We create
one instance for every update in the Outline to get the right icons.

Take a shortcut here and just use the element name directly, ignoring
packages names etc.

This is a hot fix for 2.1, a following patch will change the Icon
retrieval API accordingly.

Reviewed-by: Roberto Raggi
Task-number: QTCREATORBUG-2859
parent 75e2d424
......@@ -367,11 +367,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
m_treePos.append(0);
m_currentItem = invisibleRootItem();
// Set up lookup context once to do the element type lookup
//
// We're simplifying here by using the root context everywhere; should be
// ok since there is AFAIK no way to introduce new type names in a sub-context.
m_context = semanticInfo.lookupContext();
m_typeToIcon.clear();
m_itemToNode.clear();
m_itemToIdNode.clear();
......@@ -381,8 +376,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
QmlOutlineModelSync syncModel(this);
syncModel(m_semanticInfo.document);
m_context.clear();
emit updated();
}
......@@ -815,26 +808,18 @@ AST::SourceLocation QmlOutlineModel::getLocation(AST::ExpressionNode *exprNode)
}
QIcon QmlOutlineModel::getIcon(AST::UiQualifiedId *qualifiedId) {
const Interpreter::Value *value = m_context->evaluate(qualifiedId);
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
do {
QString module;
QString typeName;
if (const Interpreter::QmlObjectValue *qmlObjectValue =
dynamic_cast<const Interpreter::QmlObjectValue*>(objectValue)) {
module = qmlObjectValue->packageName();
}
typeName = objectValue->className();
QIcon icon = m_icons->icon(module, typeName);
if (! icon.isNull())
return icon;
QIcon icon;
if (qualifiedId) {
QString name = asString(qualifiedId);
if (name.contains(QLatin1Char('.')))
name = name.split(QLatin1Char('.')).last();
objectValue = objectValue->prototype(m_context->context());
} while (objectValue);
// TODO: get rid of namespace prefixes.
icon = m_icons->icon("Qt", name);
if (icon.isNull())
icon = m_icons->icon("QtWebkit", name);
}
return QIcon();
return icon;
}
QString QmlOutlineModel::getAnnotation(AST::UiObjectInitializer *objectInitializer) {
......
......@@ -120,7 +120,6 @@ private:
QStandardItem *m_currentItem;
QmlJS::Icons *m_icons;
QmlJS::LookupContext::Ptr m_context;
QHash<QString, QIcon> m_typeToIcon;
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;
......
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