summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@theqtcompany.com>2016-05-09 12:58:38 +0300
committerAntti Määttä <antti.maatta@qt.io>2016-05-09 10:14:40 +0000
commited7845098f59e5d4df7af681bc15777c0e4ca1d3 (patch)
tree0ae98d71312ba46229727c733a06d4d7eef366c1
parent9f6f06c31906c5261e578d742c48f39c0d867f37 (diff)
Fix threading issue in creating static opengl context
Add mutex lock for static opengl context creation. Task-number: QTBUG-53202 Change-Id: Iba22339776ec8885efd82b13ae56f6781a426f4b Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 3966a4cd77..968ef7bd3b 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -139,7 +139,8 @@ struct QWindowsIntegrationPrivate
# endif
#endif
#ifndef QT_NO_OPENGL
- QSharedPointer<QWindowsStaticOpenGLContext> m_staticOpenGLContext;
+ QMutex m_staticContextLock;
+ QScopedPointer<QWindowsStaticOpenGLContext> m_staticOpenGLContext;
#endif // QT_NO_OPENGL
QScopedPointer<QPlatformInputContext> m_inputContext;
#ifndef QT_NO_ACCESSIBILITY
@@ -435,8 +436,9 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
if (!integration)
return 0;
QWindowsIntegrationPrivate *d = integration->d.data();
+ QMutexLocker lock(&d->m_staticContextLock);
if (d->m_staticOpenGLContext.isNull())
- d->m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
+ d->m_staticOpenGLContext.reset(QWindowsStaticOpenGLContext::create());
return d->m_staticOpenGLContext.data();
}
#endif // !QT_NO_OPENGL