diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-01-26 15:48:19 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-01-28 20:46:08 +0000 |
commit | 48ae2dac07fc15cfbcd79632305ba0f88a850459 (patch) | |
tree | b71cdd005ef7abcca1d3fd3e6ba2772c39aaf56f /src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp | |
parent | 0192ab52e2f14d5914755af5ceb24172f11b6bc7 (diff) |
eglfs: fix cleanup when more than one tlw was used
There is nothing guaranteeing there is a context current when the
backingstore dtor is invoked for widget windows that do not contain
render-to-texture widgets. In some cases the eglfs compositor's
context is still current, while in other cases (esp. when having
popups and other top-levels) there is none.
To prevent not releasing the backingstore texture and the incorrect
warning about incorrect context, make the correct context current via
an offscreen surface, when necessary.
Change-Id: Id8257650c1ec8cf96910a4f285b779419c3558a8
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp')
-rw-r--r-- | src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp index fee3146f04..07a1e77c3a 100644 --- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp +++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp @@ -34,6 +34,7 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QWindow> #include <QtGui/QPainter> +#include <QtGui/QOffscreenSurface> #include <qpa/qplatformbackingstore.h> #include <private/qwindow_p.h> @@ -82,13 +83,28 @@ QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore() { if (m_bsTexture) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); + // With render-to-texture-widgets QWidget makes sure the TLW's shareContext() is + // made current before destroying backingstores. That is however not the case for + // windows with regular widgets only. + QScopedPointer<QOffscreenSurface> tempSurface; + if (!ctx) { + ctx = QOpenGLCompositor::instance()->context(); + tempSurface.reset(new QOffscreenSurface); + tempSurface->setFormat(ctx->format()); + tempSurface->create(); + ctx->makeCurrent(tempSurface.data()); + } + if (ctx && m_bsTextureContext && ctx->shareGroup() == m_bsTextureContext->shareGroup()) glDeleteTextures(1, &m_bsTexture); else qWarning("QOpenGLCompositorBackingStore: Texture is not valid in the current context"); + + if (tempSurface) + ctx->doneCurrent(); } - delete m_textures; + delete m_textures; // this does not actually own any GL resources } QPaintDevice *QOpenGLCompositorBackingStore::paintDevice() @@ -254,6 +270,7 @@ void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &sta if (m_bsTexture) { glDeleteTextures(1, &m_bsTexture); m_bsTexture = 0; + m_bsTextureContext = Q_NULLPTR; } } |