diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index e61982fae8c..a25cb385d30 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -317,8 +317,7 @@ void StatesEditorView::setWhenCondition(int internalNodeId, const QString &condi return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); @@ -338,8 +337,7 @@ void StatesEditorView::resetWhenCondition(int internalNodeId) return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); @@ -359,8 +357,7 @@ void StatesEditorView::setStateAsDefault(int internalNodeId) return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); @@ -380,8 +377,7 @@ void StatesEditorView::resetDefaultState() return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); try { if (rootModelNode().hasProperty("state")) @@ -403,8 +399,7 @@ void StatesEditorView::setAnnotation(int internalNodeId) return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); @@ -433,8 +428,7 @@ void StatesEditorView::removeAnnotation(int internalNodeId) return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); @@ -555,8 +549,7 @@ void StatesEditorView::variantPropertiesChanged(const QList &pr return; m_block = true; - auto guard = [this](int* p) { m_block = false; delete p; }; - std::unique_ptr scopeGuard(new int, guard); + auto guard = qScopeGuard([&]() { m_block = false; }); for (const VariantProperty &property : propertyList) { if (property.name() == "name" && QmlModelState::isValidQmlModelState(property.parentModelNode()))