summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>2016-01-07 13:20:08 +0100
committerMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>2016-01-11 10:06:26 +0000
commit2b1f01426c1ee47474b4b8e4e53799d992d0711c (patch)
tree65c7cf87fc90fed9e99a03c49294b480ac1322e4 /src
parent558f69a18b0ac2a54fdbc44377ef963c8db89ad6 (diff)
WinRT: Fix application shutdown
Do not create a dummy eglDisplay when the global static is constructed. This causes ANGLE to wrongly set some internals, which breaks usage of EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE as the attribute map might be empty after calling eglGetPlatformDisplayEXT. Furthermore initialize() assigns a new display to it without terminating the old one. This way, the internal suspend handler in ANGLE (Trim11.cpp) will be added to the application. The suspend handler is not invoked when an application suspends though. Reason being that the handler needs to be added from inside the Xaml thread. As we cannot control this inside ANGLE, we will call eglInitialize inside the Xaml thread and hence get the suspend event properly. Task-number: QTBUG-50337 Task-number: QTBUG-50292 Change-Id: I3867377254c37084bf24f18e78af467f6237db57 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index 3fd0278360..ebd15d7184 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -54,9 +54,6 @@ QT_BEGIN_NAMESPACE
struct WinRTEGLDisplay
{
WinRTEGLDisplay() {
- eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (eglDisplay == EGL_NO_DISPLAY)
- qCritical("Failed to initialize EGL display: 0x%x", eglGetError());
}
~WinRTEGLDisplay() {
eglTerminate(eglDisplay);
@@ -117,9 +114,17 @@ void QWinRTEGLContext::initialize()
if (g->eglDisplay == EGL_NO_DISPLAY)
qCritical("Failed to initialize EGL display: 0x%x", eglGetError());
- if (!eglInitialize(g->eglDisplay, nullptr, nullptr))
- qCritical("Failed to initialize EGL: 0x%x", eglGetError());
-
+ // eglInitialize checks for EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE
+ // which adds a suspending handler. This needs to be added from the Xaml
+ // thread itself, otherwise it will not be invoked. add_Suspending does
+ // not return an error unfortunately, so it silently fails and causes
+ // applications to not quit when the system wants to terminate the app
+ // after suspend.
+ hr = QEventDispatcherWinRT::runOnXamlThread([]() {
+ if (!eglInitialize(g->eglDisplay, nullptr, nullptr))
+ qCritical("Failed to initialize EGL: 0x%x", eglGetError());
+ return S_OK;
+ });
d->eglConfig = q_configFromGLFormat(g->eglDisplay, d->format);
const EGLint flags = d->format.testOption(QSurfaceFormat::DebugContext)