diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-20 15:14:13 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-18 22:52:12 +0200 |
commit | e2e8900bfa9dcd240ae2c20217b67f9dbbb2a645 (patch) | |
tree | 6a6bb85c1953662fb948c387453f3c448928f373 /src/quickshapes | |
parent | 598a9054be59466419f611df0b19702c41818db3 (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
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 239a90b8d5588bc6536cb81bbba7af8cc049d945)
Reviewed-by: Laszlo Agocs <laszlo.agocs@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 e0df739987..e9bc715952 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(); + } } } } |