StatesEditorView: replace custom scope guard with qScopeGuard

Change-Id: I87379e50fb652ed27692f78470d9bf706d5abfe8
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Michael Winkelmann
2021-03-22 16:49:14 +01:00
parent a10ee88437
commit 0c7cb42e5f

View File

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