diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-02-22 17:38:37 -0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-10 20:20:25 +0000 |
commit | bf87df0d98708129b01d816bb9a6cca0d9f1f1bb (patch) | |
tree | 6fce3385e9051838bdb89bc74f9daacd5e206efb | |
parent | a4ed7c4506a49b07c3e760810cfd5fba28beefab (diff) |
tst_QTimer: suppress the cross-thread timer stopping warnings
Both QTimer's and QObjectPrivate's destructors print a warning if the
current object lives on another thread and has an active timer:
QWARN : tst_QTimer::moveToThread() QObject::killTimer: Timers cannot be stopped from another thread
QWARN : tst_QTimer::moveToThread() QObject::~QObject: Timers cannot be stopped from another thread
This timer is used to ask the thread to quit, which in turn allows us to
destroy this QObject without a cross-thread warning. Because it's
already fired once and done its duty, we can make sure it's not active
by simply making it single-shot.
Change-Id: Ieec322d73c1e40ad95c8fffd17465067b27c044b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 5f32c9edce208125f642c86a4bc9e73564386243)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 15e08a50a2..e2bde37a7e 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -512,6 +512,7 @@ void tst_QTimer::moveToThread() #endif QTimer ti1; QTimer ti2; + ti1.setSingleShot(true); ti1.start(MOVETOTHREAD_TIMEOUT); ti2.start(MOVETOTHREAD_TIMEOUT); QVERIFY((ti1.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff)); |