diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-01-28 13:00:17 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-30 22:09:38 +0100 |
commit | 8e1cc7043ff53353187f5617af9b75d49e802013 (patch) | |
tree | 3cdd4f6b3cf88c5ae3439df18afd268c40b5adbd /src/corelib | |
parent | 8e26730fb7296e42d050aaa3b4af65a17f512701 (diff) |
Fix WinRT timer dispatch
This fixes the event dispatcher lookup on timer callbacks, which was
incorrectly using only the gui event dispatcher to look up timers.
Change-Id: Ia01a07f6505afd0adfc0641e9c60199f258138a1
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index 8639e925cd..cd843a4986 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -94,16 +94,7 @@ public: private: - static HRESULT timerExpiredCallback(ABI::Windows::System::Threading::IThreadPoolTimer *source); - static int idForTimer(IThreadPoolTimer *timer) - { - QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher(); - if (!eventDispatcher) - return -1; - if (QEventDispatcherWinRTPrivate *that = static_cast<QEventDispatcherWinRTPrivate *>(get(eventDispatcher))) - return that->timerIds.value(timer, -1); - return -1; - } + static HRESULT timerExpiredCallback(IThreadPoolTimer *timer); QHash<int, WinRTTimerInfo*> timerDict; QHash<IThreadPoolTimer *, int> timerIds; @@ -365,8 +356,8 @@ void QEventDispatcherWinRTPrivate::registerTimer(WinRTTimerInfo *t) void QEventDispatcherWinRTPrivate::unregisterTimer(WinRTTimerInfo *t) { if (t->timer) { - t->timer->Cancel(); timerIds.remove(t->timer.Get()); + t->timer->Cancel(); } timerDict.remove(t->id); delete t; @@ -389,13 +380,22 @@ void QEventDispatcherWinRTPrivate::sendTimerEvent(int timerId) } } -HRESULT QEventDispatcherWinRTPrivate::timerExpiredCallback(IThreadPoolTimer *source) +HRESULT QEventDispatcherWinRTPrivate::timerExpiredCallback(IThreadPoolTimer *timer) { - int timerId = idForTimer(source); - if (timerId > 0) - QCoreApplication::postEvent(QCoreApplication::eventDispatcher(), new QTimerEvent(timerId)); - else - qWarning("QEventDispatcherWinRT::timerExpiredCallback: Could not find timer %d in timer list", source); + QThread *thread = QThread::currentThread(); + if (!thread) + return E_FAIL; + + QAbstractEventDispatcher *eventDispatcher = thread->eventDispatcher(); + if (!eventDispatcher) + return E_FAIL; + + QEventDispatcherWinRTPrivate *d = static_cast<QEventDispatcherWinRTPrivate *>(get(eventDispatcher)); + int timerId = d->timerIds.value(timer, -1); + if (timerId < 0) + return E_FAIL; // A callback was received after the timer was canceled + + QCoreApplication::postEvent(eventDispatcher, new QTimerEvent(timerId)); return S_OK; } |