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
This commit is contained in:
Martin Gräßlin 2014-04-28 10:59:34 +02:00
parent 4851be6e1e
commit af5a855da4

View File

@ -224,7 +224,7 @@ bool WindowThumbnail::windowToTextureGLX(WindowTextureNode *textureNode)
size.setWidth(geo->width); size.setWidth(geo->width);
size.setHeight(geo->height); size.setHeight(geo->height);
} }
textureNode->reset(window()->createTextureFromId(m_texture, size)); textureNode->reset(window()->createTextureFromId(m_texture, size, QQuickWindow::TextureOwnsGLTexture));
} }
textureNode->texture()->bind(); textureNode->texture()->bind();
bindGLXTexture(); bindGLXTexture();
@ -269,7 +269,7 @@ bool WindowThumbnail::xcbWindowToTextureEGL(WindowTextureNode *textureNode)
size.setWidth(geo->width); size.setWidth(geo->width);
size.setHeight(geo->height); size.setHeight(geo->height);
} }
textureNode->reset(window()->createTextureFromId(m_texture, size)); textureNode->reset(window()->createTextureFromId(m_texture, size, QQuickWindow::TextureOwnsGLTexture));
} }
textureNode->texture()->bind(); textureNode->texture()->bind();
bindEGLTexture(); bindEGLTexture();
@ -314,6 +314,20 @@ void WindowThumbnail::windowToTexture(WindowTextureNode *textureNode)
return; return;
} }
#if HAVE_XCB_COMPOSITE #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) { if (m_pixmap == XCB_PIXMAP_NONE) {
m_pixmap = pixmapForWindow(); m_pixmap = pixmapForWindow();
} }