From af5a855da42c3ada2f0e802c68ad8f7c0e73b38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 28 Apr 2014 10:59:34 +0200 Subject: [PATCH] Discard window thumbnail pixmap after texture got destroyed by SceneGraph If the window holding the WindowThumbnail item goes away the texture hold by the node is destroyed but our bound window pixmap is not yet freed. This results in incorrect state the next time the WindowThumbnail is shown. To get back into a clean state discardPixmap() is called if there is no texture but a bound low level pixmap. BUG: 333482 REVIEW: 117824 --- .../core/windowthumbnail.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/core/windowthumbnail.cpp b/src/declarativeimports/core/windowthumbnail.cpp index d1a7fef1f..0c3d1e6af 100644 --- a/src/declarativeimports/core/windowthumbnail.cpp +++ b/src/declarativeimports/core/windowthumbnail.cpp @@ -224,7 +224,7 @@ bool WindowThumbnail::windowToTextureGLX(WindowTextureNode *textureNode) size.setWidth(geo->width); size.setHeight(geo->height); } - textureNode->reset(window()->createTextureFromId(m_texture, size)); + textureNode->reset(window()->createTextureFromId(m_texture, size, QQuickWindow::TextureOwnsGLTexture)); } textureNode->texture()->bind(); bindGLXTexture(); @@ -269,7 +269,7 @@ bool WindowThumbnail::xcbWindowToTextureEGL(WindowTextureNode *textureNode) size.setWidth(geo->width); size.setHeight(geo->height); } - textureNode->reset(window()->createTextureFromId(m_texture, size)); + textureNode->reset(window()->createTextureFromId(m_texture, size, QQuickWindow::TextureOwnsGLTexture)); } textureNode->texture()->bind(); bindEGLTexture(); @@ -314,6 +314,20 @@ void WindowThumbnail::windowToTexture(WindowTextureNode *textureNode) return; } #if HAVE_XCB_COMPOSITE + if (!textureNode->texture()) { + // the texture got discarded by the scene graph, but our mapping is still valid + // let's discard the pixmap to have a clean state again +#if HAVE_GLX + if (m_glxPixmap != XCB_PIXMAP_NONE) { + discardPixmap(); + } +#endif +#if HAVE_EGL + if (m_image != EGL_NO_IMAGE_KHR) { + discardPixmap(); + } +#endif + } if (m_pixmap == XCB_PIXMAP_NONE) { m_pixmap = pixmapForWindow(); }