Qml Designer: fixes nasty crash bug in Navigator

We have to use LinkAction instead of MoveAction
otherwise the model and the ItemView executes
the move/reparenting which turns the ItemModel
invalid and results in a crash
This commit is contained in:
Thomas Hartmann
2010-01-08 17:13:33 +01:00
parent 82352c0819
commit 12f6c8f631
2 changed files with 6 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ NavigatorTreeModel::NavigatorTreeModel(QObject *parent)
setHorizontalHeaderItem(1, new QStandardItem(tr("Type"))); setHorizontalHeaderItem(1, new QStandardItem(tr("Type")));
setHorizontalHeaderItem(2, new QStandardItem(tr("Show in Editor"))); setHorizontalHeaderItem(2, new QStandardItem(tr("Show in Editor")));
setSupportedDragActions(Qt::MoveAction); setSupportedDragActions(Qt::LinkAction);
connect(this, SIGNAL(itemChanged(QStandardItem*)), connect(this, SIGNAL(itemChanged(QStandardItem*)),
this, SLOT(handleChangedItem(QStandardItem*))); this, SLOT(handleChangedItem(QStandardItem*)));
@@ -60,7 +60,7 @@ NavigatorTreeModel::~NavigatorTreeModel()
Qt::DropActions NavigatorTreeModel::supportedDropActions() const Qt::DropActions NavigatorTreeModel::supportedDropActions() const
{ {
return Qt::MoveAction; return Qt::LinkAction;
} }
QStringList NavigatorTreeModel::mimeTypes() const QStringList NavigatorTreeModel::mimeTypes() const
@@ -113,7 +113,7 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
{ {
if (action == Qt::IgnoreAction) if (action == Qt::IgnoreAction)
return true; return true;
if (action != Qt::MoveAction) if (action != Qt::LinkAction)
return false; return false;
if (!data->hasFormat("application/vnd.modelnode.list")) if (!data->hasFormat("application/vnd.modelnode.list"))
return false; return false;
@@ -159,7 +159,8 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *data,
if (!isAnchestorInList(node, nodeList)) { if (!isAnchestorInList(node, nodeList)) {
if (node.parentProperty().parentModelNode() != parentItemNode) { if (node.parentProperty().parentModelNode() != parentItemNode) {
QmlItemNode itemNode(node); QmlItemNode itemNode(node);
itemNode.setParent(parentItemNode); if (node != parentItemNode)
itemNode.setParent(parentItemNode);
} }
if (node.parentProperty().isNodeListProperty()) { if (node.parentProperty().isNodeListProperty()) {

View File

@@ -46,6 +46,7 @@ NavigatorWidget::NavigatorWidget(QWidget* parent) :
m_treeView->setAcceptDrops(true); m_treeView->setAcceptDrops(true);
m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_treeView->header()->setStretchLastSection(false); m_treeView->header()->setStretchLastSection(false);
m_treeView->setDefaultDropAction(Qt::LinkAction);
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0); layout->setSpacing(0);