From c83eefff976a5f2cd673f6b4a95922b13855dd29 Mon Sep 17 00:00:00 2001
From: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Date: Tue, 24 Nov 2015 21:08:56 +0100
Subject: [PATCH] Remove incorrect assertion from the backingstore

The ifdef gave an impression of the code path being hit only when
texture-backed widgets are present and OpenGL-based compositing is
active. This is false. Asserting on having a context current is
wrong (as shown by autotests on the 5.6 branch).

Change-Id: I2539f0aac75b26597f49f63edcd9580428be79b7
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
---
 src/gui/painting/qplatformbackingstore.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 70ab9825e9e..22f5662c348 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -66,11 +66,14 @@ public:
     {
 #ifndef QT_NO_OPENGL
         QOpenGLContext *ctx = QOpenGLContext::currentContext();
-        Q_ASSERT(ctx);
-        if (textureId)
-            ctx->functions()->glDeleteTextures(1, &textureId);
-        if (blitter)
-            blitter->destroy();
+        if (ctx) {
+            if (textureId)
+                ctx->functions()->glDeleteTextures(1, &textureId);
+            if (blitter)
+                blitter->destroy();
+        } else if (textureId || blitter) {
+            qWarning("No context current during QPlatformBackingStore destruction, OpenGL resources not released");
+        }
         delete blitter;
 #endif
     }
-- 
GitLab