Separate ForceDisable from LastCheckCrashed.

This commit is contained in:
John Preston 2024-05-27 17:50:59 +04:00
parent f1d0a67d41
commit b21a93f3ba
2 changed files with 23 additions and 5 deletions

View file

@ -33,6 +33,7 @@ namespace Ui::GL {
namespace { namespace {
bool ForceDisabled/* = false*/; bool ForceDisabled/* = false*/;
bool LastCheckCrashed/* = false*/;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
ANGLE ResolvedANGLE/* = ANGLE::Auto*/; ANGLE ResolvedANGLE/* = ANGLE::Auto*/;
@ -59,9 +60,14 @@ void CrashCheckStart() {
const char kOptionAllowLinuxNvidiaOpenGL[] = "allow-linux-nvidia-opengl"; const char kOptionAllowLinuxNvidiaOpenGL[] = "allow-linux-nvidia-opengl";
Capabilities CheckCapabilities(QWidget *widget, bool avoidWidgetCreation) { Capabilities CheckCapabilities(QWidget *widget, bool avoidWidgetCreation) {
if (!Platform::IsMac()) {
if (ForceDisabled) { if (ForceDisabled) {
LOG_ONCE(("OpenGL: Force-disabled.")); LOG_ONCE(("OpenGL: Force-disabled."));
return {}; return {};
} else if (LastCheckCrashed) {
LOG_ONCE(("OpenGL: Last-crashed."));
return {};
}
} }
[[maybe_unused]] static const auto BugListInited = [] { [[maybe_unused]] static const auto BugListInited = [] {
@ -243,8 +249,17 @@ Backend ChooseBackendDefault(Capabilities capabilities) {
return use ? Backend::OpenGL : Backend::Raster; 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() { bool LastCrashCheckFailed() {
return QFile::exists(Integration::Instance().openglCheckFilePath()); DetectLastCheckCrash();
return LastCheckCrashed;
} }
void CrashCheckFinish() { void CrashCheckFinish() {
@ -252,8 +267,10 @@ void CrashCheckFinish() {
} }
void ForceDisable(bool disable) { void ForceDisable(bool disable) {
if (!Platform::IsMac()) {
ForceDisabled = disable; ForceDisabled = disable;
} }
}
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View file

@ -31,6 +31,7 @@ struct Capabilities {
void ForceDisable(bool disable); void ForceDisable(bool disable);
void DetectLastCheckCrash();
[[nodiscard]] bool LastCrashCheckFailed(); [[nodiscard]] bool LastCrashCheckFailed();
void CrashCheckFinish(); void CrashCheckFinish();