Skip to content
Snippets Groups Projects
Commit 12f6c8f6 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

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
parent 82352c08
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ NavigatorTreeModel::NavigatorTreeModel(QObject *parent) ...@@ -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() ...@@ -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, ...@@ -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, ...@@ -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()) {
......
...@@ -46,6 +46,7 @@ NavigatorWidget::NavigatorWidget(QWidget* parent) : ...@@ -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);
......
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