Commit a835b514 authored by Robert Loehning's avatar Robert Loehning

Centralize checking for OpenGL

Change-Id: Ic2212c8519f4c771ba3e3c61dd32073b93db7ed9
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 0e8a0cac
......@@ -30,6 +30,9 @@
#include "hostosinfo.h"
#include <QApplication>
#include <QOpenGLContext>
#ifdef Q_OS_WIN
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 /* WinXP, needed for GetNativeSystemInfo() */
......@@ -81,3 +84,12 @@ void HostOsInfo::unsetOverrideFileNameCaseSensitivity()
{
m_useOverrideFileNameCaseSensitivity = false;
}
bool HostOsInfo::canCreateOpenGLContext(QString *errorMessage)
{
static const bool canCreate = QOpenGLContext().create();
if (!canCreate)
*errorMessage = QApplication::translate("Utils::HostOsInfo",
"Cannot create OpenGL context.");
return canCreate;
}
......@@ -84,6 +84,8 @@ public:
return hostOsAspects().controlModifier();
}
static bool canCreateOpenGLContext(QString *errorMessage);
private:
static OsSpecificAspects hostOsAspects() { return OsSpecificAspects(hostOs()); }
......
......@@ -61,7 +61,6 @@
#include <qplugin.h>
#include <QDebug>
#include <QProcessEnvironment>
#include <QOpenGLContext>
namespace QmlDesigner {
......@@ -127,10 +126,8 @@ QmlDesignerPlugin::~QmlDesignerPlugin()
////////////////////////////////////////////////////
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/) // =0;
{
if (!QOpenGLContext().create()) {
*errorMessage = tr("Cannot create OpenGL context.");
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
return false;
}
data = new QmlDesignerPluginData;
......
......@@ -36,8 +36,8 @@
#include <analyzerbase/analyzermanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/hostosinfo.h>
#include <QOpenGLContext>
#include <QtPlugin>
using namespace Analyzer;
......@@ -54,10 +54,8 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
{
Q_UNUSED(arguments)
if (!QOpenGLContext().create()) {
*errorString = tr("Cannot create OpenGL context.");
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorString))
return false;
}
auto tool = new QmlProfilerTool(this);
auto widgetCreator = [tool] { return tool->createWidgets(); };
......
......@@ -51,7 +51,6 @@
#include <QMessageBox>
#include <QDir>
#include <QOpenGLContext>
#include <QQmlPropertyMap>
#ifdef USE_QUICK_WIDGET
......@@ -289,10 +288,8 @@ WelcomePlugin::WelcomePlugin()
bool WelcomePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
{
if (!QOpenGLContext().create()) {
*errorMessage = tr("Cannot create OpenGL context.");
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
return false;
}
m_welcomeMode = new WelcomeMode;
addAutoReleasedObject(m_welcomeMode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment