summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2016-11-24 15:44:57 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2017-01-03 14:11:20 +0000
commit0eb522cae723a3d7cf8b55ed237ae501ee0c7132 (patch)
tree7e066aa26ac2fdb5e1c942751ec6d19b9b815eff /src
parent6ff945052063710f2857be12631fa91759759786 (diff)
winrt: Check for removed timers after sending events
After all the check makes sense here. If a timer was removed as a result of sendEvent and it was not at the end of the list the list is not shrunk but the timer info's id is just set to INVALID_TIMER_ID. Additionally the timer's object should be fetched before we unlock the locker as timerIdToObject is changed in removeTimer and we might access a nullptr if the timer has been removed. Reverts c83ba01f7bc542368973f3f24dfb59c6052dd78a Task-number: QTBUG-56756 Change-Id: Ib1a04c02fbfcf4c939b4891d42f954dc9e87149e Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> (cherry picked from commit 8f2088db171a6941feb1903a2912a8b7fdf3a9ec)
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 6126ff0e5d..4b7081b4a7 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -115,7 +115,7 @@ private:
timerIdToHandle.insert(id, handle);
timerIdToCancelHandle.insert(id, cancelHandle);
}
- timerIdToObject.insert(id, obj);
+
const quint64 targetTime = qt_msectime() + interval;
const WinRTTimerInfo info(id, interval, type, obj, targetTime);
QMutexLocker locker(&timerInfoLock);
@@ -521,15 +521,18 @@ bool QEventDispatcherWinRT::event(QEvent *e)
break;
info.inEvent = true;
+ QObject *timerObj = d->timerIdToObject.value(id);
locker.unlock();
QTimerEvent te(id);
- QCoreApplication::sendEvent(d->timerIdToObject.value(id), &te);
+ QCoreApplication::sendEvent(timerObj, &te);
locker.relock();
- // The timer might have been removed in the meanwhile
- if (id >= d->timerInfos.size())
+ // The timer might have been removed in the meanwhile. If the timer was
+ // the last one in the list, id is bigger than the list's size.
+ // Otherwise, the id will just be set to INVALID_TIMER_ID.
+ if (id >= d->timerInfos.size() || info.timerId == INVALID_TIMER_ID)
break;
if (info.interval == 0 && info.inEvent) {