From 5da5586a96bbb80e46065b1da847126b9fdb558f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 3 Jan 2017 18:33:56 +0100 Subject: 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 --- src/plugins/platforms/ios/qiosbackingstore.mm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm index 076e34c1a5..96be28af81 100644 --- a/src/plugins/platforms/ios/qiosbackingstore.mm +++ b/src/plugins/platforms/ios/qiosbackingstore.mm @@ -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; } -- cgit v1.2.3