From 496147fd3f5fc0518149ad93b177a32b2541d80c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 15 Aug 2022 13:34:07 +0200 Subject: [PATCH] vkkhrdisplay: Create the platform window always No matter what the surface type was. We only support VulkanSurface, so if the type is something else, then a a qWarning is in order, but instead of returning nullptr (which will almost certainly cause a fail or crash in some form), we can just carry on normally. The resulting window will not be renderable from the application of course, but that is not always needed in fact, plus failing gracefully is nicer. The tst_qrhi autotest can now be run on the RPi4 also with -platform vkkhrdisplay. While there are some odd messages occurring from Mesa and co., the run now completes normally, with no failures. Change-Id: I77bd249096aede8e05458559458581d702054540 Reviewed-by: Andy Nichols (cherry picked from commit e025b07c64a44e0fdf05b34bd183177d18a295a2) Reviewed-by: Qt Cherry-pick Bot --- .../platforms/vkkhrdisplay/qvkkhrdisplayintegration.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/vkkhrdisplay/qvkkhrdisplayintegration.cpp b/src/plugins/platforms/vkkhrdisplay/qvkkhrdisplayintegration.cpp index 411cda4af8b..502c2518f25 100644 --- a/src/plugins/platforms/vkkhrdisplay/qvkkhrdisplayintegration.cpp +++ b/src/plugins/platforms/vkkhrdisplay/qvkkhrdisplayintegration.cpp @@ -219,7 +219,11 @@ QPlatformWindow *QVkKhrDisplayIntegration::createPlatformWindow(QWindow *window) { if (window->surfaceType() != QSurface::VulkanSurface) { qWarning("vkkhrdisplay platform plugin only supports QWindow with surfaceType == VulkanSurface"); - return nullptr; + // Assume VulkanSurface, better than crashing. Consider e.g. an autotest + // creating a default QWindow just to have something to be used with + // QRhi's Null backend. Continuing to set up a Vulkan window (even + // though the request was Raster or something) is better than failing to + // create a platform window, and may even be sufficient in some cases. } QVkKhrDisplayWindow *w = new QVkKhrDisplayWindow(window);