From a4ac4b326318ed9034466305222280ed8d1651b5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Oct 2014 14:39:06 +0200 Subject: QWindowsGuiEventDispatcher: Register timers in constructor. Port change 3716a76704273fdbe5ad4ec978438daeda606c26 (Qt 4) to Qt 5. Enforce the creation of the internal window and registering of timers in the event dispatcher constructor for GUI applications instead of delaying it to processEvents() is called. Move the call to virtual wakeUp() out of createInternalHwnd(). Task-number: QTBUG-40881 Change-Id: I82a4748897da140a39feff882c75ad5ac6155148 Reviewed-by: Joerg Bornemann --- src/corelib/kernel/qeventdispatcher_win.cpp | 8 +++----- src/corelib/kernel/qeventdispatcher_win_p.h | 2 +- src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 7816edd3f9..a3d00faf31 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -639,7 +639,6 @@ void QEventDispatcherWin32::createInternalHwnd() { Q_D(QEventDispatcherWin32); - Q_ASSERT(!d->internalHwnd); if (d->internalHwnd) return; d->internalHwnd = qt_create_internal_window(this); @@ -664,9 +663,6 @@ void QEventDispatcherWin32::createInternalHwnd() // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); - - // trigger a call to sendPostedEvents() - wakeUp(); } QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) @@ -686,8 +682,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWin32); - if (!d->internalHwnd) + if (!d->internalHwnd) { createInternalHwnd(); + wakeUp(); // trigger a call to sendPostedEvents() + } d->interrupt = false; emit awake(); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index f9bb06a5c5..369c276615 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -65,8 +65,8 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher Q_OBJECT Q_DECLARE_PRIVATE(QEventDispatcherWin32) +protected: void createInternalHwnd(); - friend class QGuiEventDispatcherWin32; public: explicit QEventDispatcherWin32(QObject *parent = 0); diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp index 73988b6db5..593b5eac7a 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp @@ -62,6 +62,7 @@ QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : QEventDispatcherWin32(parent), m_flags(0) { setObjectName(QStringLiteral("QWindowsGuiEventDispatcher")); + createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc. } bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) -- cgit v1.2.3