forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -367,11 +367,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
|
|||||||
m_treePos.append(0);
|
m_treePos.append(0);
|
||||||
m_currentItem = invisibleRootItem();
|
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_typeToIcon.clear();
|
||||||
m_itemToNode.clear();
|
m_itemToNode.clear();
|
||||||
m_itemToIdNode.clear();
|
m_itemToIdNode.clear();
|
||||||
@@ -381,8 +376,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
|
|||||||
QmlOutlineModelSync syncModel(this);
|
QmlOutlineModelSync syncModel(this);
|
||||||
syncModel(m_semanticInfo.document);
|
syncModel(m_semanticInfo.document);
|
||||||
|
|
||||||
m_context.clear();
|
|
||||||
|
|
||||||
emit updated();
|
emit updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,26 +808,18 @@ AST::SourceLocation QmlOutlineModel::getLocation(AST::ExpressionNode *exprNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QIcon QmlOutlineModel::getIcon(AST::UiQualifiedId *qualifiedId) {
|
QIcon QmlOutlineModel::getIcon(AST::UiQualifiedId *qualifiedId) {
|
||||||
const Interpreter::Value *value = m_context->evaluate(qualifiedId);
|
QIcon icon;
|
||||||
|
if (qualifiedId) {
|
||||||
|
QString name = asString(qualifiedId);
|
||||||
|
if (name.contains(QLatin1Char('.')))
|
||||||
|
name = name.split(QLatin1Char('.')).last();
|
||||||
|
|
||||||
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
|
// TODO: get rid of namespace prefixes.
|
||||||
do {
|
icon = m_icons->icon("Qt", name);
|
||||||
QString module;
|
if (icon.isNull())
|
||||||
QString typeName;
|
icon = m_icons->icon("QtWebkit", name);
|
||||||
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;
|
return icon;
|
||||||
|
|
||||||
objectValue = objectValue->prototype(m_context->context());
|
|
||||||
} while (objectValue);
|
|
||||||
}
|
|
||||||
return QIcon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlOutlineModel::getAnnotation(AST::UiObjectInitializer *objectInitializer) {
|
QString QmlOutlineModel::getAnnotation(AST::UiObjectInitializer *objectInitializer) {
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ private:
|
|||||||
QStandardItem *m_currentItem;
|
QStandardItem *m_currentItem;
|
||||||
QmlJS::Icons *m_icons;
|
QmlJS::Icons *m_icons;
|
||||||
|
|
||||||
QmlJS::LookupContext::Ptr m_context;
|
|
||||||
QHash<QString, QIcon> m_typeToIcon;
|
QHash<QString, QIcon> m_typeToIcon;
|
||||||
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
|
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
|
||||||
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;
|
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;
|
||||||
|
|||||||
Reference in New Issue
Block a user