set default format for QSurface to handle NVidia context loss events
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 17 Sep 2021 07:54:25 +0000 (09:54 +0200)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Wed, 22 Sep 2021 08:56:16 +0000 (08:56 +0000)
should fix wrong OpenGL rendering after suspend on Linux with NVidia
binary OpenGL driver

close #3759

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/main.cpp

index ec4a347eb839da7c659cb4965581c567d0346289..ef5747974dcacc33e527185b17c4ec4c5a8b6a77 100644 (file)
@@ -39,6 +39,7 @@
 #include <QDebug>
 #include <QQuickStyle>
 #include <QQuickWindow>
+#include <QSurfaceFormat>
 
 using namespace OCC;
 
@@ -113,6 +114,10 @@ int main(int argc, char **argv)
     }
 #endif
 
+    auto surfaceFormat = QSurfaceFormat::defaultFormat();
+    surfaceFormat.setOption(QSurfaceFormat::ResetNotification);
+    QSurfaceFormat::setDefaultFormat(surfaceFormat);
+
 // check a environment variable for core dumps
 #ifdef Q_OS_UNIX
     if (!qEnvironmentVariableIsEmpty("OWNCLOUD_CORE_DUMP")) {