mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Add OpenGL init crash checker.
This commit is contained in:
parent
0fde35f59e
commit
750c13e5fe
7 changed files with 64 additions and 4 deletions
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/emoji_keywords.h"
|
||||
#include "chat_helpers/stickers_emoji_image_loader.h"
|
||||
#include "base/platform/base_platform_last_input.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "mainwindow.h"
|
||||
#include "dialogs/dialogs_entry.h"
|
||||
|
@ -281,6 +282,36 @@ void Application::run() {
|
|||
for (const auto &error : Shortcuts::Errors()) {
|
||||
LOG(("Shortcuts Error: %1").arg(error));
|
||||
}
|
||||
|
||||
if (!Platform::IsMac()
|
||||
&& Ui::Integration::Instance().openglLastCheckFailed()) {
|
||||
showOpenGLCrashNotification();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::showOpenGLCrashNotification() {
|
||||
const auto enable = [=] {
|
||||
Ui::GL::ForceDisable(false);
|
||||
Ui::Integration::Instance().openglCheckFinish();
|
||||
Core::App().settings().setDisableOpenGL(false);
|
||||
Local::writeSettings();
|
||||
App::restart();
|
||||
};
|
||||
const auto keepDisabled = [=] {
|
||||
Ui::GL::ForceDisable(true);
|
||||
Ui::Integration::Instance().openglCheckFinish();
|
||||
Core::App().settings().setDisableOpenGL(true);
|
||||
Local::writeSettings();
|
||||
};
|
||||
_window->show(Box<ConfirmBox>(
|
||||
"Last time OpenGL crashed on initialization. "
|
||||
"Perhaps it is a problem with your graphics card driver.\n\n"
|
||||
"Right now OpenGL was disabled. You can try to enable it back "
|
||||
"or keep it disabled, if it continues crashing.",
|
||||
"Enable",
|
||||
"Keep Disabled",
|
||||
enable,
|
||||
keepDisabled));
|
||||
}
|
||||
|
||||
void Application::startDomain() {
|
||||
|
|
|
@ -299,13 +299,12 @@ private:
|
|||
void startEmojiImageLoader();
|
||||
void startSystemDarkModeViewer();
|
||||
|
||||
void stateChanged(Qt::ApplicationState state);
|
||||
|
||||
friend void App::quit();
|
||||
static void QuitAttempt();
|
||||
void quitDelayed();
|
||||
[[nodiscard]] bool readyToQuit();
|
||||
|
||||
void showOpenGLCrashNotification();
|
||||
void clearPasscodeLock();
|
||||
|
||||
bool openCustomUrl(
|
||||
|
|
|
@ -510,7 +510,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_emojiVariants = std::move(emojiVariants);
|
||||
_disableOpenGL = (disableOpenGL == 1);
|
||||
if (!Platform::IsMac()) {
|
||||
Ui::GL::ForceDisable(_disableOpenGL);
|
||||
Ui::GL::ForceDisable(_disableOpenGL
|
||||
|| Ui::Integration::Instance().openglLastCheckFailed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/sandbox.h"
|
||||
#include "base/concurrent_timer.h"
|
||||
|
||||
//#include <QtCore/QLoggingCategory>
|
||||
|
||||
namespace Core {
|
||||
namespace {
|
||||
|
||||
|
@ -525,6 +527,7 @@ void Launcher::processArguments() {
|
|||
int Launcher::executeApplication() {
|
||||
FilteredCommandLineArguments arguments(_argc, _argv);
|
||||
Sandbox sandbox(this, arguments.count(), arguments.values());
|
||||
//QLoggingCategory::setFilterRules("qt.qpa.gl.debug=true");
|
||||
Ui::MainQueueProcessor processor;
|
||||
base::ConcurrentTimerEnvironment environment;
|
||||
return sandbox.start();
|
||||
|
|
|
@ -85,6 +85,10 @@ const auto kBadPrefix = u"http://"_q;
|
|||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] QString OpenGLCheckFilePath() {
|
||||
return cWorkingDir() + "tdata/opengl_crash_check";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void UiIntegration::postponeCall(FnMut<void()> &&callable) {
|
||||
|
@ -103,6 +107,22 @@ QString UiIntegration::emojiCacheFolder() {
|
|||
return cWorkingDir() + "tdata/emoji";
|
||||
}
|
||||
|
||||
void UiIntegration::openglCheckStart() {
|
||||
auto f = QFile(OpenGLCheckFilePath());
|
||||
if (f.open(QIODevice::WriteOnly)) {
|
||||
f.write("1", 1);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
void UiIntegration::openglCheckFinish() {
|
||||
QFile::remove(OpenGLCheckFilePath());
|
||||
}
|
||||
|
||||
bool UiIntegration::openglLastCheckFailed() {
|
||||
return QFile::exists(OpenGLCheckFilePath());
|
||||
}
|
||||
|
||||
void UiIntegration::textActionsUpdated() {
|
||||
if (const auto window = App::wnd()) {
|
||||
window->updateGlobalMenu();
|
||||
|
|
|
@ -38,6 +38,10 @@ public:
|
|||
|
||||
QString emojiCacheFolder() override;
|
||||
|
||||
void openglCheckStart() override;
|
||||
void openglCheckFinish() override;
|
||||
bool openglLastCheckFailed() override;
|
||||
|
||||
void textActionsUpdated() override;
|
||||
void activationFromTopPanel() override;
|
||||
|
||||
|
@ -71,4 +75,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
[[nodiscard]] bool OpenglLastCheckFailed();
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 802918dd11eba3382ae9607babf01db47e232f58
|
||||
Subproject commit f58fd1b9277301d1d5a167fc0809558425ce608e
|
Loading…
Add table
Reference in a new issue