diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-10-02 17:42:18 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-10-05 14:09:27 +0000 |
commit | d69b36b28135701693ead85f93716648fafce25f (patch) | |
tree | 0e6301226618df9fc2931a48d4d26065a8f51417 | |
parent | df13f01741a9c78ba2f5858c39e0c38a858e2438 (diff) |
QScxmlEventConnection: fix binding loops
By using (set)ValueBypassingBindings() in property setters.
Also convert the helper function doConnect() to use
valueBypassingBindings(), as it's only called from the setters.
Task-number: QTBUG-116542
Pick-to: 6.5
Change-Id: I6ab241c26d377b62e99b46b3295cfa48ef5f2a7b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit d86fa5e76b2f13633bc557579bde5f0dcc36ab76)
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r-- | src/scxmlqml/eventconnection.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/scxmlqml/eventconnection.cpp b/src/scxmlqml/eventconnection.cpp index 4171438..f3c7589 100644 --- a/src/scxmlqml/eventconnection.cpp +++ b/src/scxmlqml/eventconnection.cpp @@ -56,11 +56,11 @@ QStringList QScxmlEventConnection::events() const void QScxmlEventConnection::setEvents(const QStringList &events) { - if (events == m_events.value()) { - m_events.removeBindingUnlessInWrapper(); + m_events.removeBindingUnlessInWrapper(); + if (events == m_events.valueBypassingBindings()) { return; } - m_events = events; + m_events.setValueBypassingBindings(events); doConnect(); m_events.notify(); } @@ -77,11 +77,10 @@ QScxmlStateMachine *QScxmlEventConnection::stateMachine() const void QScxmlEventConnection::setStateMachine(QScxmlStateMachine *stateMachine) { - if (stateMachine == m_stateMachine.value()) { - m_stateMachine.removeBindingUnlessInWrapper(); + m_stateMachine.removeBindingUnlessInWrapper(); + if (stateMachine == m_stateMachine.valueBypassingBindings()) return; - } - m_stateMachine = stateMachine; + m_stateMachine.setValueBypassingBindings(stateMachine); doConnect(); m_stateMachine.notify(); } @@ -96,10 +95,12 @@ void QScxmlEventConnection::doConnect() for (const QMetaObject::Connection &connection : std::as_const(m_connections)) disconnect(connection); m_connections.clear(); - if (m_stateMachine) { - for (const QString &event : std::as_const(m_events.value())) { - m_connections.append(m_stateMachine->connectToEvent(event, this, - &QScxmlEventConnection::occurred)); + const auto stateMachine = m_stateMachine.valueBypassingBindings(); + if (stateMachine) { + const auto events = m_events.valueBypassingBindings(); + for (const QString &event : events) { + m_connections.append(stateMachine->connectToEvent(event, this, + &QScxmlEventConnection::occurred)); } } } |