diff options
| author | Zoltan Gera <zoltan.gera@qt.io> | 2024-11-14 10:52:33 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-11-22 05:18:02 +0000 |
| commit | 66fbe87b31f622d922f0fd50954fa918578ca63f (patch) | |
| tree | 7a4f8c9c80051c2faa4a05721b01acb4a189143e | |
| parent | 8931affd3849ea50b6ab7916640c05c690e16b3a (diff) | |
Tests: Fix CmdListener reconnect on destruction problem
CmdListener greedily reconnects on a disconnect signal even when it is
just being destroyed. This behavior is theoretically wrong and can
cause assertions on certian platform combinations. (win11 and mingw in
this case)
Fixes: QTBUG-130868
Change-Id: Iebbe9a264db8c6322d62e5d3591bf2a4afa04815
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
(cherry picked from commit d28823724554180acc854da3db1ce242073ce842)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8661a87ef4e25d17356601eb12d4a2c853447004)
| -rw-r--r-- | tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.cpp | 7 | ||||
| -rw-r--r-- | tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.h | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.cpp b/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.cpp index 4cc2db7d..2110a606 100644 --- a/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.cpp +++ b/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.cpp @@ -16,9 +16,14 @@ CmdListener::CmdListener(QObject *parent) emit newCmd(cmd); } }); - connect(socket, &QLocalSocket::disconnected, [socket]() { + m_reconnectingConnection = connect(socket, &QLocalSocket::disconnected, [socket]() { socket->connectToServer("qifcmdsocket"); }); } +CmdListener::~CmdListener() +{ + disconnect(m_reconnectingConnection); +} + #include "moc_cmdlistener.cpp" diff --git a/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.h b/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.h index ef0de9c7..4a535ad7 100644 --- a/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.h +++ b/tests/auto/core/ifcodegen/backends/cmdlistener/cmdlistener.h @@ -15,9 +15,13 @@ class CMDLISTENER_EXPORT CmdListener : public QObject public: explicit CmdListener(QObject *parent = nullptr); + virtual ~CmdListener() override; Q_SIGNALS: void newCmd(const QString &cmd); + +private: + QMetaObject::Connection m_reconnectingConnection; }; #endif // CMDLISTENER_H |
