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-04 14:22:28 +0200 |
commit | d86fa5e76b2f13633bc557579bde5f0dcc36ab76 (patch) | |
tree | a9291bb67692efe68b902abd3c22d214c4521ad1 /src/scxmlqml | |
parent | 48a4f0007b91a5fd562823b6d28317e0580b142c (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.6 6.5
Change-Id: I6ab241c26d377b62e99b46b3295cfa48ef5f2a7b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/scxmlqml')
-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)); } } } |