summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglversionfunctions.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2016-12-26 18:37:47 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2017-01-06 12:42:29 +0000
commitfb85a72325d7954592ac88bbe82c913ae6124424 (patch)
tree0fb6cfaf974391788e8e0cb0477bd94c52cbe41c /src/gui/opengl/qopenglversionfunctions.cpp
parentafbdf20fed389fe56a948d166c7c62693f04ba6c (diff)
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 <simon.hausmann@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopenglversionfunctions.cpp')
-rw-r--r--src/gui/opengl/qopenglversionfunctions.cpp18
1 files changed, 12 insertions, 6 deletions
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<QOpenGLFunctions_##X##Backend*>(backends[i]); \
+ ++i;
+
+ QT_OPENGL_VERSIONS(DELETE_BACKEND)
+#undef DELETE_BACKEND
delete[] backends;
}
+#endif
}
QOpenGLVersionFunctionsBackend *QOpenGLVersionFunctionsStorage::backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v)