mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #7463 from zzmp/guard/bugsplat-2177
Guard against lack of GL support to avoid crash
This commit is contained in:
commit
9a66d779ae
6 changed files with 63 additions and 10 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "AddressManager.h"
|
||||
#include "Application.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "UserActivityLogger.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#ifdef HAS_BUGSPLAT
|
||||
|
@ -102,11 +103,19 @@ int main(int argc, const char* argv[]) {
|
|||
// Check OpenGL version.
|
||||
// This is done separately from the main Application so that start-up and shut-down logic within the main Application is
|
||||
// not made more complicated than it already is.
|
||||
bool override = false;
|
||||
QString glVersion;
|
||||
{
|
||||
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
||||
if (!openGLVersionChecker.isValidVersion()) {
|
||||
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
||||
return 0;
|
||||
bool valid = true;
|
||||
glVersion = openGLVersionChecker.checkVersion(valid, override);
|
||||
if (!valid) {
|
||||
if (override) {
|
||||
qCDebug(interfaceapp, "Running on insufficient OpenGL version: %s.", glVersion.toStdString().c_str());
|
||||
} else {
|
||||
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,6 +143,22 @@ int main(int argc, const char* argv[]) {
|
|||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
Application app(argc, const_cast<char**>(argv), startupTime);
|
||||
|
||||
// If we failed the OpenGLVersion check, log it.
|
||||
if (override) {
|
||||
auto& accountManager = AccountManager::getInstance();
|
||||
if (accountManager.isLoggedIn()) {
|
||||
UserActivityLogger::getInstance().insufficientGLVersion(glVersion);
|
||||
} else {
|
||||
QObject::connect(&AccountManager::getInstance(), &AccountManager::loginComplete, [glVersion](){
|
||||
static bool loggedInsufficientGL = false;
|
||||
if (!loggedInsufficientGL) {
|
||||
UserActivityLogger::getInstance().insufficientGLVersion(glVersion);
|
||||
loggedInsufficientGL = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Setup local server
|
||||
QLocalServer server { &app };
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ void GLWidget::initializeGL() {
|
|||
// TODO: write the proper code for linux
|
||||
makeCurrent();
|
||||
#if defined(Q_OS_WIN)
|
||||
_vsyncSupported = context()->contextHandle()->hasExtension("WGL_EXT_swap_control");;
|
||||
if (isValid() && context() && context()->contextHandle()) {
|
||||
_vsyncSupported = context()->contextHandle()->hasExtension("WGL_EXT_swap_control");;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,26 @@ OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
|||
{
|
||||
}
|
||||
|
||||
bool OpenGLVersionChecker::isValidVersion() {
|
||||
bool valid = true;
|
||||
QString OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||
valid = true;
|
||||
override = false;
|
||||
|
||||
// Retrieve OpenGL version
|
||||
GLWidget* glWidget = new GLWidget();
|
||||
valid = glWidget->isValid();
|
||||
// Inform user if no OpenGL support
|
||||
if (!valid) {
|
||||
QMessageBox messageBox;
|
||||
messageBox.setWindowTitle("Missing OpenGL Support");
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
messageBox.setText(QString().sprintf("Your system does not support OpenGL, Interface cannot run."));
|
||||
messageBox.setInformativeText("Press OK to exit.");
|
||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
messageBox.exec();
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Retrieve OpenGL version
|
||||
glWidget->initializeGL();
|
||||
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
||||
delete glWidget;
|
||||
|
@ -54,8 +69,8 @@ bool OpenGLVersionChecker::isValidVersion() {
|
|||
messageBox.setInformativeText("Press OK to exit; Ignore to continue.");
|
||||
messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Ignore);
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
valid = messageBox.exec() == QMessageBox::Ignore;
|
||||
override = messageBox.exec() == QMessageBox::Ignore;
|
||||
}
|
||||
|
||||
return valid;
|
||||
return glVersion;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class OpenGLVersionChecker : public QApplication {
|
|||
public:
|
||||
OpenGLVersionChecker(int& argc, char** argv);
|
||||
|
||||
static bool isValidVersion();
|
||||
static QString checkVersion(bool& valid, bool& override);
|
||||
};
|
||||
|
||||
#endif // hifi_OpenGLVersionChecker_h
|
||||
|
|
|
@ -85,6 +85,15 @@ void UserActivityLogger::launch(QString applicationVersion, bool previousSession
|
|||
logAction(ACTION_NAME, actionDetails);
|
||||
}
|
||||
|
||||
void UserActivityLogger::insufficientGLVersion(QString glVersion) {
|
||||
const QString ACTION_NAME = "insufficient_gl";
|
||||
QJsonObject actionDetails;
|
||||
QString GL_VERSION = "glVersion";
|
||||
actionDetails.insert(GL_VERSION, glVersion);
|
||||
|
||||
logAction(ACTION_NAME, actionDetails);
|
||||
}
|
||||
|
||||
void UserActivityLogger::changedDisplayName(QString displayName) {
|
||||
const QString ACTION_NAME = "changed_display_name";
|
||||
QJsonObject actionDetails;
|
||||
|
|
|
@ -30,6 +30,8 @@ public slots:
|
|||
void logAction(QString action, QJsonObject details = QJsonObject(), JSONCallbackParameters params = JSONCallbackParameters());
|
||||
|
||||
void launch(QString applicationVersion, bool previousSessionCrashed, int previousSessionRuntime);
|
||||
|
||||
void insufficientGLVersion(QString glVersion);
|
||||
|
||||
void changedDisplayName(QString displayName);
|
||||
void changedModel(QString typeOfModel, QString modelURL);
|
||||
|
|
Loading…
Reference in a new issue