From b21a93f3ba47d6233a0feb764be37850ae1edcb2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 27 May 2024 17:50:59 +0400 Subject: [PATCH] Separate ForceDisable from LastCheckCrashed. --- ui/gl/gl_detection.cpp | 27 ++++++++++++++++++++++----- ui/gl/gl_detection.h | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index 150eb8b..a6707af 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -33,6 +33,7 @@ namespace Ui::GL { namespace { bool ForceDisabled/* = false*/; +bool LastCheckCrashed/* = false*/; #ifdef Q_OS_WIN ANGLE ResolvedANGLE/* = ANGLE::Auto*/; @@ -59,9 +60,14 @@ void CrashCheckStart() { const char kOptionAllowLinuxNvidiaOpenGL[] = "allow-linux-nvidia-opengl"; Capabilities CheckCapabilities(QWidget *widget, bool avoidWidgetCreation) { - if (ForceDisabled) { - LOG_ONCE(("OpenGL: Force-disabled.")); - return {}; + if (!Platform::IsMac()) { + if (ForceDisabled) { + LOG_ONCE(("OpenGL: Force-disabled.")); + return {}; + } else if (LastCheckCrashed) { + LOG_ONCE(("OpenGL: Last-crashed.")); + return {}; + } } [[maybe_unused]] static const auto BugListInited = [] { @@ -243,8 +249,17 @@ Backend ChooseBackendDefault(Capabilities capabilities) { return use ? Backend::OpenGL : Backend::Raster; } +void DetectLastCheckCrash() { + [[maybe_unused]] static const auto Once = [] { + LastCheckCrashed = !Platform::IsMac() + && QFile::exists(Integration::Instance().openglCheckFilePath()); + return false; + }(); +} + bool LastCrashCheckFailed() { - return QFile::exists(Integration::Instance().openglCheckFilePath()); + DetectLastCheckCrash(); + return LastCheckCrashed; } void CrashCheckFinish() { @@ -252,7 +267,9 @@ void CrashCheckFinish() { } void ForceDisable(bool disable) { - ForceDisabled = disable; + if (!Platform::IsMac()) { + ForceDisabled = disable; + } } #ifdef Q_OS_WIN diff --git a/ui/gl/gl_detection.h b/ui/gl/gl_detection.h index 97e6606..5b23fa7 100644 --- a/ui/gl/gl_detection.h +++ b/ui/gl/gl_detection.h @@ -31,6 +31,7 @@ struct Capabilities { void ForceDisable(bool disable); +void DetectLastCheckCrash(); [[nodiscard]] bool LastCrashCheckFailed(); void CrashCheckFinish();