diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-20 15:14:13 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-21 10:21:14 +0200 |
commit | 239a90b8d5588bc6536cb81bbba7af8cc049d945 (patch) | |
tree | ecafae976d0ebf918c75d7417517ef6325684d0c /src/quickshapes | |
parent | a0d216bf5acdf136982fcd0746115d942238c0ec (diff) |
shapes: Avoid upsetting Mesa on eglfs with kms
We need to either ensure the context is destroyed before the offscreen
surface, or make sure the context is not current (and so the surface is
not associated with it anymore) when it is destroyed. We choose the
latter here.
Change-Id: If4424b98c4d8a718aa49d99285360ded6a5e128e
Fixes: QTBUG-82371
Pick-to: 5.15
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quickshapes')
-rw-r--r-- | src/quickshapes/qquickshapegenericrenderer.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp index 91716981d8..50cdc60d52 100644 --- a/src/quickshapes/qquickshapegenericrenderer.cpp +++ b/src/quickshapes/qquickshapegenericrenderer.cpp @@ -123,10 +123,11 @@ static bool q_supportsElementIndexUint(QSGRendererInterface::GraphicsApi api) if (!elementIndexUintChecked) { elementIndexUintChecked = true; QOpenGLContext *context = QOpenGLContext::currentContext(); + const bool needsTempContext = !context; QScopedPointer<QOpenGLContext> dummyContext; QScopedPointer<QOffscreenSurface> dummySurface; bool ok = true; - if (!context) { + if (needsTempContext) { dummyContext.reset(new QOpenGLContext); dummyContext->create(); context = dummyContext.data(); @@ -138,6 +139,13 @@ static bool q_supportsElementIndexUint(QSGRendererInterface::GraphicsApi api) if (ok) { elementIndexUint = static_cast<QOpenGLExtensions *>(context->functions())->hasOpenGLExtension( QOpenGLExtensions::ElementIndexUint); + + if (needsTempContext) { + // Must not let the temprary context be destroyed while current and + // the associated surface already gone, because some implementations + // (Mesa on drm) do not like that. + context->doneCurrent(); + } } } } |