winrt: Exclude user events when adding/removing windows

Handling user events while creating a window can cause problems and
crashes as the event tries to access non initialized parts of the window
itself being created. Hence exclude user input events at that time and
have them handled when the event loop checks for them regularly.

Change-Id: I2a78efd619250be8f6f2e737ed78e39481a4cf76
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Maurice Kalinowski 2016-08-22 12:07:16 +02:00 committed by Jani Heikkinen
parent 75ef5859b6
commit c8a6b4278b

View File

@ -767,7 +767,7 @@ void QWinRTScreen::addWindow(QWindow *window)
updateWindowTitle(window->title());
QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason);
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents();
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
#if _MSC_VER >= 1900 && !defined(QT_NO_DRAGANDDROP)
QWinRTDrag::instance()->setDropTarget(window);
@ -785,7 +785,7 @@ void QWinRTScreen::removeWindow(QWindow *window)
if (wasTopWindow)
QWindowSystemInterface::handleWindowActivated(Q_NULLPTR, Qt::OtherFocusReason);
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents();
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
#if _MSC_VER >= 1900 && !defined(QT_NO_DRAGANDDROP)
if (wasTopWindow)
QWinRTDrag::instance()->setDropTarget(topWindow());