From 0c7cb42e5f7901fb1863f3f29682e22ed88e91c9 Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Mon, 22 Mar 2021 16:49:14 +0100 Subject: [PATCH] StatesEditorView: replace custom scope guard with qScopeGuard Change-Id: I87379e50fb652ed27692f78470d9bf706d5abfe8 Reviewed-by: Aleksei German Reviewed-by: Thomas Hartmann --- .../stateseditor/stateseditorview.cpp | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) 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()))