diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-03-04 11:40:29 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-04-11 09:21:05 +0000 |
commit | 025473e2c4f533052a4ed0654e5a8414a4d8af55 (patch) | |
tree | 74b9a556014f532aa83a4bfba029180ed13a6b8a | |
parent | 9dffc5dd18c466950325454706b10e08edf24231 (diff) |
Avoid crashing if WebContext is accessed before initialized
While it is better to use the global shared OpenGL context, we can
fall back to using the module type which is usually correct.
Change-Id: I441bfdc38db593abfd10cb08ba90af09dcd31a2a
Task-number: QTBUG-51379
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | src/core/web_engine_context.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 9a96f695e..a3b12b742 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -105,7 +105,9 @@ void destroyContext() bool usingANGLE() { #if defined(Q_OS_WIN) - return qt_gl_global_share_context()->isOpenGLES(); + if (qt_gl_global_share_context()) + return qt_gl_global_share_context()->isOpenGLES(); + return QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES; #else return false; #endif @@ -263,10 +265,23 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisableGpu); } else { const char *glType = 0; - if (qt_gl_global_share_context()->isOpenGLES()) { - glType = gfx::kGLImplementationEGLName; + if (qt_gl_global_share_context()) { + if (qt_gl_global_share_context()->isOpenGLES()) { + glType = gfx::kGLImplementationEGLName; + } else { + glType = gfx::kGLImplementationDesktopName; + } } else { - glType = gfx::kGLImplementationDesktopName; + qWarning("WebEngineContext used before QtWebEngine::initialize()"); + // We have to assume the default OpenGL module type will be used. + switch (QOpenGLContext::openGLModuleType()) { + case QOpenGLContext::LibGL: + glType = gfx::kGLImplementationDesktopName; + break; + case QOpenGLContext::LibGLES: + glType = gfx::kGLImplementationEGLName; + break; + } } parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType); |