iOS: Ensure that QPlatformBackingStore can clean up textures in dtor

We are using QPlatformBackingStore::composeAndFlush, which allocates
textures on our behalf using the context that we pass in, so we need
to keep the context alive (and make it current) for the duration of
the QPlatformBackingStore destructor, otherwise we're leaking textures
every time a window (dialog e.g.) is closed.

Change-Id: I1450fa0ff7a170d13ec59920566e4401b50cd513
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-01-03 18:33:56 +01:00
parent 3c99bddb84
commit 5da5586a96

View File

@ -122,7 +122,17 @@ QIOSBackingStore::QIOSBackingStore(QWindow *window)
QIOSBackingStore::~QIOSBackingStore()
{
delete m_context;
if (window()->surfaceType() == QSurface::RasterGLSurface) {
// We're using composeAndFlush from QPlatformBackingStore, which
// need to clean up any textures in its destructor, so make the
// context current and keep it alive until QPlatformBackingStore
// has cleaned up everything.
makeCurrent();
m_context->deleteLater();
} else {
delete m_context;
}
delete m_glDevice;
}