From 4a439143baf75b9a00cf17a3b7a34ae9ac93c68a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 13 Jul 2021 14:15:06 +0100 Subject: [PATCH] Fix a crash when creating views on the placeholder screen When a compositor has no outputs listed Qt creates a dummy placeholder QScreen object that does not represent a wl_output. This should still be fixed in the clients to not create a view, it's wasteful and probably will still have plenty of other bugs, hence the giant warning, but it's still worth guarding. CCBUG: 439096 --- src/qwaylandlayersurface.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index e45db1e..5a95d74 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -8,6 +8,7 @@ #include "interfaces/shell.h" #include "qwaylandlayershell_p.h" #include "qwaylandlayersurface_p.h" +#include "layershellqt_logging.h" #include #include @@ -22,7 +23,14 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandC LayerShellQt::Window *interface = Window::get(window->window()); Q_ASSERT(interface); - init(shell->get_layer_surface(window->waylandSurface()->object(), window->waylandScreen()->output(), interface->layer(), interface->scope())); + // Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created + // this will not cast to a QWaylandScreen + QtWaylandClient::QWaylandScreen *screen = window->waylandScreen(); + if (screen->isPlaceholder()) { + qCWarning(LAYERSHELLQT) << "Creating a layer shell for placeholder screen. This will be positioned incorrectly"; + } + + init(shell->get_layer_surface(window->waylandSurface()->object(), screen->isPlaceholder() ? nullptr : screen->output(), interface->layer(), interface->scope())); Window::Anchors anchors = interface->anchors();