From 3fb422693e24c9b330582f694cd791811898ebd9 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 21 Jun 2024 04:56:47 +0400 Subject: [PATCH] Fix setting alpha buffer size in Ui::GL::CheckCapabilities fo Qt 6.4+ --- ui/gl/gl_detection.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index fa3bcbdd..91738b2e 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -90,30 +90,24 @@ Capabilities CheckCapabilities(QWidget *widget) { return true; }(); - auto format = QSurfaceFormat(); - if (widget) { - if (!widget->window()->windowHandle()) { - widget->window()->createWinId(); - } - if (!widget->window()->windowHandle()) { - LOG(("OpenGL: Could not create window for widget.")); - return {}; - } - format = widget->window()->windowHandle()->format(); - format.setAlphaBufferSize(8); - widget->window()->windowHandle()->setFormat(format); - } else { - format.setAlphaBufferSize(8); - } - CrashCheckStart(); + const auto guard = gsl::finally([=] { + CrashCheckFinish(); + }); + auto tester = QOpenGLWidget(widget); - tester.setFormat(format); - tester.grabFramebuffer(); // Force initialize(). if (!tester.window()->windowHandle()) { tester.window()->createWinId(); } - CrashCheckFinish(); + if (!tester.window()->windowHandle()) { + LOG(("OpenGL: Could not create window for widget.")); + return {}; + } + auto format = tester.window()->windowHandle()->format(); + format.setAlphaBufferSize(8); + tester.window()->windowHandle()->setFormat(format); + tester.setFormat(format); + tester.grabFramebuffer(); // Force initialize(). const auto context = tester.context(); if (!context