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

View File

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