summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets/textdocument-frames/mainwindow.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-12-03 15:35:14 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-12-06 19:01:19 +0100
commita3bec3ad371de67c890a435e025db37be44c3333 (patch)
tree1ba23608481a8935fcce77c1a96a5240500502ee /src/gui/doc/snippets/textdocument-frames/mainwindow.cpp
parent85842da95b5a7821b44d83e5d26922a3d07ef6cf (diff)
Don't clear Qt::Window/ForeignWindow of QWidget if window is not top level
The logic was needed for the old QMacCocoaViewContainer, which was a QWidget, that set Qt::ForeignWindow, and hence Qt::Window, on its windowHandle(). The modern way of embedding a foreign window into a widget hierarchy is via QWindow::fromWinId() and QWidget::createWindowContainer(), which manages the foreign window as a child QWindow of the window container's window handle, instead of replacing or modifying the window container's own window handle. The opposite case is a QWidget embedded into a foreign/non-widget window hierarchy. Ideally, in this case, we should return false for isWindow(), as the function is documented to only return true for "if the widget is an independent window", and "a window is a widget that isn't visually the child of any other widget and that usually has a frame and a window title". This notion is used in many places, including in QApplication::topLevelWidgets(), which in turn affects the quit logic of QApplication to prevent quitting the application as long as the child/embedded widget is visible. Unfortunately, embedding the widget as a non-Qt::Window is not an option at this point, as we have a lot of code paths that assume isWindow() || parentWidget(), and these code paths break down in flames when we end up dereferencing the (non existing) parent widget. As a result of removing the logic, we can now embed a QWidget into a non-widget window hierarchy as a Qt::Window, without the removed logic resetting the widget back to a Qt::Widget on create(), which would send us into into the broken code paths described above. Removing this logic should not cause issues for child widgets backed by a native window, as those are created with Qt::Widget window flags, not Qt::Window, so we never relied on the removed logic to sanitize those window flags. Task-number: QTBUG-119652 Change-Id: Id6b8e5c67bf8f83af8c2f1594806f3419303b1a1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/gui/doc/snippets/textdocument-frames/mainwindow.cpp')
0 files changed, 0 insertions, 0 deletions