Skip to content
Snippets Groups Projects
Commit 666724b2 authored by Kai Koehne's avatar Kai Koehne
Browse files

Fix assert in WriteLogger because of misbehaving Navigator

The Navigator "called back" to the model in case e.g. the id
of an item changed. This was catched by the WriteLogger, which
lead to an assert.

Fix this by tracking whether we are changing the navigator items
due to a model change, and not reacting to itemChanged signal
in this case.
parent 34751f4a
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,8 @@
namespace QmlDesigner {
NavigatorTreeModel::NavigatorTreeModel(QObject *parent)
: QStandardItemModel(parent)
: QStandardItemModel(parent),
m_blockItemChangedSignal(false)
{
invisibleRootItem()->setFlags(Qt::NoItemFlags);
......@@ -205,9 +206,13 @@ NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &n
void NavigatorTreeModel::updateItemRow(const ModelNode &node, ItemRow items)
{
bool blockSignal = blockItemChangedSignal(true);
items.idItem->setText(node.id());
items.typeItem->setText(node.simplifiedTypeName());
items.visibilityItem->setCheckState(node.auxiliaryData("invisible").toBool() ? Qt::Unchecked : Qt::Checked);
blockItemChangedSignal(blockSignal);
}
/**
......@@ -217,6 +222,7 @@ void NavigatorTreeModel::updateItemRow(const ModelNode &node)
{
if (!containsNode(node))
return;
updateItemRow(node, itemRowForNode(node));
}
......@@ -227,6 +233,7 @@ void NavigatorTreeModel::updateItemRowOrder(const ModelNode &node)
{
if (!containsNode(node))
return;
ItemRow itemRow = itemRowForNode(node);
int currentRow = itemRow.idItem->row();
int newRow = currentRow;
......@@ -243,6 +250,9 @@ void NavigatorTreeModel::updateItemRowOrder(const ModelNode &node)
void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
{
if (m_blockItemChangedSignal)
return;
uint nodeHash = item->data(Qt::UserRole).toUInt();
Q_ASSERT(nodeHash && containsNodeHash(nodeHash));
ModelNode node = nodeForHash(nodeHash);
......@@ -394,5 +404,14 @@ QList<ModelNode> NavigatorTreeModel::modelNodeChildren(const ModelNode &parentNo
return children;
}
// along the lines of QObject::blockSignals
bool NavigatorTreeModel::blockItemChangedSignal(bool block)
{
bool oldValue = m_blockItemChangedSignal;
m_blockItemChangedSignal = block;
return oldValue;
}
}
......@@ -103,11 +103,14 @@ private:
QList<ModelNode> modelNodeChildren(const ModelNode &parentNode);
private:
bool blockItemChangedSignal(bool block);
private:
QHash<ModelNode, ItemRow> m_nodeItemHash;
QHash<uint, ModelNode> m_nodeHash;
QWeakPointer<AbstractView> m_view;
bool m_blockItemChangedSignal;
};
} // namespace QmlDesigner
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment