From fb85a72325d7954592ac88bbe82c913ae6124424 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 18:37:47 +0100 Subject: Fix deleting of QOpenGLVersionFunctionsBackend Since the destructor is not virtual we need to cast to the proper class when deleting otherwise the wrong destructor is called and the object memory is not entirely freed. Change-Id: Ie4e0e91bfa6e802c7d72fd1f137f5c7f3f31c8a0 Reviewed-by: Simon Hausmann Reviewed-by: Marc Mutz --- src/gui/opengl/qopenglversionfunctions.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/gui/opengl/qopenglversionfunctions.cpp') diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index 54df2e5734..a3d3bb6bd1 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -74,15 +74,21 @@ QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage() QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() { +#ifndef QT_OPENGL_ES if (backends) { - for (int i = 0; i < QOpenGLVersionFunctionsBackend::OpenGLVersionBackendCount; ++i) { - if (backends[i] && !--backends[i]->refs) { - // deleting the base class is ok, as the derived classes don't have a destructor - delete backends[i]; - } - } + + int i = 0; + +#define DELETE_BACKEND(X) \ + if (backends[i] && !--backends[i]->refs) \ + delete static_cast(backends[i]); \ + ++i; + + QT_OPENGL_VERSIONS(DELETE_BACKEND) +#undef DELETE_BACKEND delete[] backends; } +#endif } QOpenGLVersionFunctionsBackend *QOpenGLVersionFunctionsStorage::backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v) -- cgit v1.2.3