forked from qt-creator/qt-creator
QmlOutline: Fix QTC_ASSERTs (finally)
Make sure all internal hashes for an item are initialized before inserting it into the tree.
This commit is contained in:
@@ -364,25 +364,22 @@ QModelIndex QmlOutlineModel::enterObjectDefinition(AST::UiObjectDefinition *objD
|
|||||||
AST::UiQualifiedId *idNode = 0;
|
AST::UiQualifiedId *idNode = 0;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|
||||||
|
data.insert(Qt::DisplayRole, typeName);
|
||||||
|
|
||||||
if (typeName.at(0).isUpper()) {
|
if (typeName.at(0).isUpper()) {
|
||||||
data.insert(ItemTypeRole, ElementType);
|
data.insert(ItemTypeRole, ElementType);
|
||||||
data.insert(AnnotationRole, getAnnotation(objDef->initializer));
|
data.insert(AnnotationRole, getAnnotation(objDef->initializer));
|
||||||
|
idNode = objDef->qualifiedTypeNameId;
|
||||||
if (!m_typeToIcon.contains(typeName)) {
|
if (!m_typeToIcon.contains(typeName)) {
|
||||||
m_typeToIcon.insert(typeName, getIcon(objDef->qualifiedTypeNameId));
|
m_typeToIcon.insert(typeName, getIcon(objDef->qualifiedTypeNameId));
|
||||||
}
|
}
|
||||||
|
|
||||||
icon = m_typeToIcon.value(typeName);
|
icon = m_typeToIcon.value(typeName);
|
||||||
idNode = objDef->qualifiedTypeNameId;
|
|
||||||
} else {
|
} else {
|
||||||
// it's a grouped propery like 'anchors'
|
// it's a grouped propery like 'anchors'
|
||||||
data.insert(ItemTypeRole, NonElementBindingType);
|
data.insert(ItemTypeRole, NonElementBindingType);
|
||||||
|
|
||||||
icon = m_icons->scriptBindingIcon();
|
icon = m_icons->scriptBindingIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
data.insert(Qt::DisplayRole, typeName);
|
|
||||||
|
|
||||||
|
|
||||||
QmlOutlineItem *item = enterNode(data, objDef, idNode, icon);
|
QmlOutlineItem *item = enterNode(data, objDef, idNode, icon);
|
||||||
|
|
||||||
return item->index();
|
return item->index();
|
||||||
@@ -517,29 +514,16 @@ QIcon QmlOutlineModel::icon(const QModelIndex &index) const
|
|||||||
QmlOutlineItem *QmlOutlineModel::enterNode(QMap<int, QVariant> data, AST::Node *node, AST::UiQualifiedId *idNode, const QIcon &icon)
|
QmlOutlineItem *QmlOutlineModel::enterNode(QMap<int, QVariant> data, AST::Node *node, AST::UiQualifiedId *idNode, const QIcon &icon)
|
||||||
{
|
{
|
||||||
int siblingIndex = m_treePos.last();
|
int siblingIndex = m_treePos.last();
|
||||||
|
QmlOutlineItem *newItem = 0;
|
||||||
if (siblingIndex == 0) {
|
if (siblingIndex == 0) {
|
||||||
// first child
|
// first child
|
||||||
if (!m_currentItem->hasChildren()) {
|
if (!m_currentItem->hasChildren()) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "QmlOutlineModel - Adding" << "element to" << m_currentItem->text();
|
qDebug() << "QmlOutlineModel - Adding" << "element to" << m_currentItem->text();
|
||||||
|
|
||||||
QmlOutlineItem *newItem = new QmlOutlineItem(this);
|
newItem = new QmlOutlineItem(this);
|
||||||
|
|
||||||
m_itemToNode.insert(newItem, node);
|
|
||||||
m_itemToIdNode.insert(newItem, idNode);
|
|
||||||
m_itemToIcon.insert(newItem, icon);
|
|
||||||
newItem->setItemData(data);
|
|
||||||
|
|
||||||
m_currentItem->appendRow(newItem);
|
|
||||||
m_currentItem = newItem;
|
|
||||||
} else {
|
} else {
|
||||||
m_currentItem = m_currentItem->child(0);
|
m_currentItem = m_currentItem->child(0);
|
||||||
QmlOutlineItem *item = static_cast<QmlOutlineItem*>(m_currentItem);
|
|
||||||
|
|
||||||
m_itemToNode.insert(item, node);
|
|
||||||
m_itemToIdNode.insert(item, idNode);
|
|
||||||
m_itemToIcon.insert(item, icon);
|
|
||||||
item->setItemData(data);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// sibling
|
// sibling
|
||||||
@@ -547,30 +531,27 @@ QmlOutlineItem *QmlOutlineModel::enterNode(QMap<int, QVariant> data, AST::Node *
|
|||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "QmlOutlineModel - Adding" << "element to" << m_currentItem->text();
|
qDebug() << "QmlOutlineModel - Adding" << "element to" << m_currentItem->text();
|
||||||
|
|
||||||
QmlOutlineItem *newItem = new QmlOutlineItem(this);
|
newItem = new QmlOutlineItem(this);
|
||||||
|
|
||||||
m_itemToNode.insert(newItem, node);
|
|
||||||
m_itemToIdNode.insert(newItem, idNode);
|
|
||||||
m_itemToIcon.insert(newItem, icon);
|
|
||||||
newItem->setItemData(data);
|
|
||||||
|
|
||||||
m_currentItem->appendRow(newItem);
|
|
||||||
m_currentItem = newItem;
|
|
||||||
} else {
|
} else {
|
||||||
m_currentItem = m_currentItem->child(siblingIndex);
|
m_currentItem = m_currentItem->child(siblingIndex);
|
||||||
QmlOutlineItem *item = static_cast<QmlOutlineItem*>(m_currentItem);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QmlOutlineItem *item = newItem ? newItem : static_cast<QmlOutlineItem*>(m_currentItem);
|
||||||
m_itemToNode.insert(item, node);
|
m_itemToNode.insert(item, node);
|
||||||
m_itemToIdNode.insert(item, idNode);
|
m_itemToIdNode.insert(item, idNode);
|
||||||
m_itemToIcon.insert(item, icon);
|
m_itemToIcon.insert(item, icon);
|
||||||
item->setItemData(data);
|
|
||||||
}
|
if (newItem) {
|
||||||
|
m_currentItem->appendRow(newItem);
|
||||||
|
m_currentItem = newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setItemData(m_currentItem->index(), data);
|
||||||
|
|
||||||
m_treePos.append(0);
|
m_treePos.append(0);
|
||||||
|
|
||||||
return static_cast<QmlOutlineItem*>(m_currentItem);
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlOutlineModel::leaveNode()
|
void QmlOutlineModel::leaveNode()
|
||||||
|
|||||||
Reference in New Issue
Block a user