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>bb10
parent
afbdf20fed
commit
fb85a72325
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue