diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 270d51239dd..f2adcf4f363 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -100,20 +100,13 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const return index.internalId(); case HasWhenCondition: - return stateNode.isValid() && stateNode.hasProperty("when"); + return stateNode.hasProperty("when"); - case WhenConditionString: { - if (stateNode.isValid() && stateNode.hasBindingProperty("when")) - return stateNode.bindingProperty("when").expression(); - else - return QString(); - } + case WhenConditionString: + return stateNode.bindingProperty("when").expression(); case IsDefault: { - QmlModelState modelState(stateNode); - if (modelState.isValid()) - return modelState.isDefault(); - return false; + return QmlModelState(stateNode).isDefault(); } case ModelHasDefaultState: diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 054a1f4e005..f70789310cc 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -346,9 +346,7 @@ void StatesEditorView::resetWhenCondition(int internalNodeId) if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); try { - if (state.isValid() && state.modelNode().hasProperty("when")) - state.modelNode().removeProperty("when"); - + state.modelNode().removeProperty("when"); } catch (const RewritingException &e) { e.showException(); } @@ -409,9 +407,7 @@ void StatesEditorView::setAnnotation(int internalNodeId) QmlModelState state(modelNodeForInternalId(internalNodeId)); try { if (state.isValid()) { - ModelNode modelNode = state.modelNode(); - - if (modelNode.isValid()) { + if (ModelNode modelNode = state.modelNode()) { if (!m_editor) m_editor = new AnnotationEditor(this);