diff options
author | Oliver Wolff <oliver.wolff@theqtcompany.com> | 2015-04-17 09:06:04 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@theqtcompany.com> | 2015-04-20 06:14:07 +0000 |
commit | d0c96c65ec5e25b1b43885a8c32a886a9b6aa834 (patch) | |
tree | ac22102069ed9bd7e2265094356d54f820d931c2 /src/corelib/kernel/qcoreapplication_win.cpp | |
parent | 848f01f9fb64c13140a1458999f2bf39ea0cb5c1 (diff) |
Rework WinRT timer handling
The former way of timer handling caused heap corruptions
as the timer callbacks tried to access the event dispatcher
after it was freed.
So instead of accessing the timers inside the callbacks
we use native events to signal their expiration and also
to cancel them.
Task-number: QTBUG-44973
Change-Id: Ib9348651c0545cc4393f0396601f9a5bb183c996
Reviewed-by: Andrew Knight <qt@panimo.net>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_win.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication_win.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 4649c151f7..396d2f740a 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -184,28 +184,6 @@ Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, #ifndef QT_NO_QOBJECT -void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) -{ - QThreadData *data = object->d_func()->threadData; - - QMutexLocker locker(&data->postEventList.mutex); - if (data->postEventList.size() == 0) - return; - for (int i = 0; i < data->postEventList.size(); ++i) { - const QPostEvent & pe = data->postEventList.at(i); - if (pe.receiver == object - && pe.event - && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent) - && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) { - --pe.receiver->d_func()->postedEvents; - pe.event->posted = false; - delete pe.event; - const_cast<QPostEvent &>(pe).event = 0; - return; - } - } -} - #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM) /***************************************************************************** Convenience functions for convert WM_* messages into human readable strings, @@ -1050,4 +1028,28 @@ QDebug operator<<(QDebug dbg, const MSG &msg) #endif // !defined(Q_OS_WINRT) +#ifndef QT_NO_QOBJECT +void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) +{ + QThreadData *data = object->d_func()->threadData; + + QMutexLocker locker(&data->postEventList.mutex); + if (data->postEventList.size() == 0) + return; + for (int i = 0; i < data->postEventList.size(); ++i) { + const QPostEvent &pe = data->postEventList.at(i); + if (pe.receiver == object + && pe.event + && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent) + && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) { + --pe.receiver->d_func()->postedEvents; + pe.event->posted = false; + delete pe.event; + const_cast<QPostEvent &>(pe).event = 0; + return; + } + } +} +#endif // QT_NO_QOBJECT + QT_END_NAMESPACE |