diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-09-03 06:17:05 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-09-04 14:22:16 (GMT) |
commit | 5323b15f50df99722d304c04d1758bb9410ef041 (patch) | |
tree | 5f074722a95e5fe968536326d6719d81455bc226 /src/corelib/kernel | |
parent | 1a60fb9506519210edcbfb3fbc400a67a6d26a41 (diff) | |
download | Qt-5323b15f50df99722d304c04d1758bb9410ef041.zip Qt-5323b15f50df99722d304c04d1758bb9410ef041.tar.gz Qt-5323b15f50df99722d304c04d1758bb9410ef041.tar.bz2 |
Fix tst_QTimer::moveToThread() on Windows
We shouldn't fully unregister timers when the event dispatcher is stopped
when a thread exits, since this releases the timerId back to the pool.
Instead, only free the OS resources.
Auto-test included.
Reviewed-by: ogoffart
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index b7934db..9c308a3 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -331,7 +331,7 @@ public: WinTimerVec timerVec; WinTimerDict timerDict; void registerTimer(WinTimerInfo *t); - void unregisterTimer(WinTimerInfo *t); + void unregisterTimer(WinTimerInfo *t, bool closingDown = false); void sendTimerEvent(int timerId); // socket notifiers @@ -557,10 +557,10 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer"); } -void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t) +void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t, bool closingDown) { // mark timer as unused - if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent) + if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent && !closingDown) QAbstractEventDispatcherPrivate::releaseTimerId(t->timerId); if (t->interval == 0) { @@ -1019,8 +1019,8 @@ void QEventDispatcherWin32::closingDown() unregisterSocketNotifier((*(d->sn_except.begin()))->obj); // clean up any timers - while (!d->timerDict.isEmpty()) - unregisterTimer((*(d->timerDict.begin()))->timerId); + for (int i = 0; i < d->timerVec.count(); ++i) + d->unregisterTimer(d->timerVec.at(i), true); } bool QEventDispatcherWin32::event(QEvent *e) |