From 00fbe73457b5040dbbf671b3e85f889240299e2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Br=C3=BCning?= <michael.bruning@digia.com>
Date: Fri, 26 Sep 2014 15:11:49 +0200
Subject: [PATCH] [Win] Use automatic destruction for PbufferGLSurfaceWGL.

PbufferGLSurfaceWGL is a reference counted class, hence deleting
it manually triggers an assert in debug builds if Release is not
called or the reference count is non-zero.

Using a scoped_refptr prevents this and deletes the object
correctly.

Change-Id: I7e5ff783afc367e06d872b8d118c2ff83627b836
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
---
 src/core/gl_surface_qt.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index cc2809af1..bc1b8b399 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -262,7 +262,7 @@ protected:
     ~GLSurfaceQtWGL();
 
 private:
-    PbufferGLSurfaceWGL *m_surfaceBuffer;
+    scoped_refptr<PbufferGLSurfaceWGL> m_surfaceBuffer;
     DISALLOW_COPY_AND_ASSIGN(GLSurfaceQtWGL);
 };
 
@@ -291,10 +291,7 @@ bool GLSurfaceQtWGL::Initialize()
 
 void GLSurfaceQtWGL::Destroy()
 {
-    if (m_surfaceBuffer) {
-        delete m_surfaceBuffer;
-        m_surfaceBuffer = 0;
-    }
+    m_surfaceBuffer = 0;
 }
 
 void *GLSurfaceQtWGL::GetHandle()
-- 
GitLab