From 4c855a9f9ff523e2753157897100393d14bf2f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 17 Jul 2017 12:13:58 +0200 Subject: Add QPlatformWindow::initialize() for two-step window creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QWindow::create method calls createPlatformWindow, and assigns the result to d->platformWindow. If the platform sends any sort of events synchronously during the creation, the event will be delivered to a QWindow that doesn't have a handle() yet, resulting in noop handling of the event, or crashes. To mitigate this situations, platforms should do as little a possible in the QPlatformWindow constructor, and leave initialization to the new method, where the QWindow will have a handle(). The macOS platform plugin still has a m_initialized guard, to prevent sending geometry changes during initialization, as this will result in a resize event before a show event. This forced behavior seems dubious, but is left for a followup patch. Task-number: QTBUG-61977 Change-Id: I04d32d93391e89d068752b719270438e7024ad46 Reviewed-by: Morten Johan Sørvig Reviewed-by: Simon Hausmann --- src/gui/kernel/qwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/kernel/qwindow.cpp') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index bd52113762..1d8d6dfc95 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -509,6 +509,8 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) return; } + platformWindow->initialize(); + QObjectList childObjects = q->children(); for (int i = 0; i < childObjects.size(); i ++) { QObject *object = childObjects.at(i); -- cgit v1.2.3