forked from qt-creator/qt-creator
QmlDesigner: Fix crash
Do not call validId in updateContext. Calling validId does mutate the model and will set an id if none exists. Since updateContext is called on selection change the user does not expect the model to mutate and when switching/creating documents this could even lead to a crash. Instead, we give the created MosueArea always an id and disable the menu in case there is no id. Task-number: QDS-7806 Change-Id: I3d5d1ce41025d94db3cfff48f483366e56b58a32 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -595,6 +595,8 @@ public:
|
|||||||
{
|
{
|
||||||
menu()->clear();
|
menu()->clear();
|
||||||
|
|
||||||
|
menu()->setEnabled(true);
|
||||||
|
|
||||||
const auto selection = selectionContext();
|
const auto selection = selectionContext();
|
||||||
if (!selection.isValid())
|
if (!selection.isValid())
|
||||||
return;
|
return;
|
||||||
@@ -604,11 +606,19 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ModelNode currentNode = selection.currentSingleSelectedNode();
|
ModelNode currentNode = selection.currentSingleSelectedNode();
|
||||||
|
|
||||||
|
if (!currentNode.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
QmlObjectNode currentObjectNode(currentNode);
|
QmlObjectNode currentObjectNode(currentNode);
|
||||||
|
|
||||||
QStringList signalsList = getSignalsList(currentNode);
|
QStringList signalsList = getSignalsList(currentNode);
|
||||||
QList<SlotEntry> slotsList = getSlotsLists(currentNode);
|
QList<SlotEntry> slotsList = getSlotsLists(currentNode);
|
||||||
currentNode.validId();
|
|
||||||
|
if (!currentNode.hasId()) {
|
||||||
|
menu()->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const ModelNode &connectionNode : currentObjectNode.getAllConnections()) {
|
for (const ModelNode &connectionNode : currentObjectNode.getAllConnections()) {
|
||||||
for (const AbstractProperty &property : connectionNode.properties()) {
|
for (const AbstractProperty &property : connectionNode.properties()) {
|
||||||
|
|||||||
@@ -1638,6 +1638,7 @@ void addMouseAreaFill(const SelectionContext &selectionContext)
|
|||||||
|
|
||||||
QmlDesigner::ModelNode mouseAreaNode =
|
QmlDesigner::ModelNode mouseAreaNode =
|
||||||
selectionContext.view()->createModelNode("QtQuick.MouseArea", itemMetaInfo.majorVersion(), itemMetaInfo.minorVersion());
|
selectionContext.view()->createModelNode("QtQuick.MouseArea", itemMetaInfo.majorVersion(), itemMetaInfo.minorVersion());
|
||||||
|
mouseAreaNode.validId();
|
||||||
|
|
||||||
modelNode.defaultNodeListProperty().reparentHere(mouseAreaNode);
|
modelNode.defaultNodeListProperty().reparentHere(mouseAreaNode);
|
||||||
QmlItemNode mouseAreaItemNode(mouseAreaNode);
|
QmlItemNode mouseAreaItemNode(mouseAreaNode);
|
||||||
|
|||||||
Reference in New Issue
Block a user