forked from qt-creator/qt-creator
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:
@@ -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,6 +159,7 @@ 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);
|
||||||
|
if (node != parentItemNode)
|
||||||
itemNode.setParent(parentItemNode);
|
itemNode.setParent(parentItemNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user