summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMÃ¥rten Nordheim <marten.nordheim@qt.io>2021-04-07 14:27:21 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-12 16:40:01 +0000
commit42c468a1994df71cdf8ca7bce61f7698091355c2 (patch)
tree26d7bfdde97cc99e07887961966aceb5cf751560 /tests/auto
parent99b269f0b73760181c25f8a62f5ea45881f7af28 (diff)
QtFuture::connect: disconnect signals first
During reportFinished we may call a continuation which might end up triggering one of the signals. Change-Id: I19546fcca12be71cd536e4287eb5eddd9d236830 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit bb85831e4de5e2c4951a0c40003ccf36f57cbd93) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 0d1097ce1c..23131ed160 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -3131,6 +3131,25 @@ void tst_QFuture::signalConnect()
QVERIFY(future.isCanceled());
QVERIFY(!future.isValid());
}
+
+ // Signal emitted, causing Sender to be destroyed
+ {
+ SenderObject *sender = new SenderObject();
+
+ auto future = QtFuture::connect(sender, &SenderObject::intArgSignal);
+ future.then([sender](int) {
+ // Scenario: Sender no longer needed, so it's deleted
+ delete sender;
+ });
+
+ QSignalSpy spy(sender, &SenderObject::destroyed);
+ emit sender->intArgSignal(5);
+ spy.wait();
+
+ QVERIFY(future.isFinished());
+ QVERIFY(!future.isCanceled());
+ QVERIFY(future.isValid());
+ }
}
void tst_QFuture::waitForFinished()