forked from qt-creator/qt-creator
QmlDesigner.dragAndDrop: crash fix
This fixes a crash if we drag in complex items with children. Change-Id: I0e924d3130cbd43dc9a20469576dce8a0f67f3df Reviewed-on: http://codereview.qt.nokia.com/1715 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -185,12 +185,20 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode
|
|||||||
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool isAncestorOf(FormEditorItem *formEditorItem, FormEditorItem *newParentItem)
|
||||||
|
{
|
||||||
|
if (formEditorItem && newParentItem)
|
||||||
|
return formEditorItem->isAncestorOf(newParentItem);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorItem * currentItem)
|
FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorItem * currentItem)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> list = scene()->items(point);
|
QList<QGraphicsItem *> list = scene()->items(point);
|
||||||
foreach (QGraphicsItem *item, list) {
|
foreach (QGraphicsItem *item, list) {
|
||||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||||
if (formEditorItem && formEditorItem != currentItem && formEditorItem->isContainer())
|
if (formEditorItem && formEditorItem != currentItem && formEditorItem->isContainer()
|
||||||
|
&& !isAncestorOf(currentItem, formEditorItem))
|
||||||
return formEditorItem;
|
return formEditorItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user