From d86fa5e76b2f13633bc557579bde5f0dcc36ab76 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 2 Oct 2023 17:42:18 +0200 Subject: 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 --- src/scxmlqml/eventconnection.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/scxmlqml') 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)); } } } -- cgit v1.2.3