From ff042bddaf85a25f0faa019d081f1dd8921ed68d Mon Sep 17 00:00:00 2001 From: Gary Buhrmaster Date: Fri, 12 Jul 2013 00:39:45 +0000 Subject: [PATCH] Eliminate memory leak in MythRenderOpenGL In commit 99e0e577d7f5aa789fbeabffae8b989a61a72288 a memory leak was introduced. This patch eliminates the use of the pointer where the lock member object is lost and replaces it by appropriate creation in the initializer. This is a "minimal" fix to the issue. Signed-off-by: Gary Buhrmaster --- mythtv/libs/libmythui/mythrender_opengl.cpp | 10 ++++------ mythtv/libs/libmythui/mythrender_opengl.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/mythtv/libs/libmythui/mythrender_opengl.cpp b/mythtv/libs/libmythui/mythrender_opengl.cpp index 671ee7964ff..1b3049aed62 100644 --- a/mythtv/libs/libmythui/mythrender_opengl.cpp +++ b/mythtv/libs/libmythui/mythrender_opengl.cpp @@ -104,14 +104,14 @@ MythRenderOpenGL* MythRenderOpenGL::Create(const QString &painter, MythRenderOpenGL::MythRenderOpenGL(const QGLFormat& format, QPaintDevice* device, RenderType type) - : QGLContext(format, device), MythRender(type) + : QGLContext(format, device), MythRender(type), m_lock(QMutex::Recursive) { ResetVars(); ResetProcs(); } MythRenderOpenGL::MythRenderOpenGL(const QGLFormat& format, RenderType type) - : QGLContext(format), MythRender(type) + : QGLContext(format), MythRender(type), m_lock(QMutex::Recursive) { ResetVars(); ResetProcs(); @@ -119,7 +119,6 @@ MythRenderOpenGL::MythRenderOpenGL(const QGLFormat& format, RenderType type) MythRenderOpenGL::~MythRenderOpenGL() { - delete m_lock; } void MythRenderOpenGL::Init(void) @@ -161,7 +160,7 @@ bool MythRenderOpenGL::IsRecommendedRenderer(void) void MythRenderOpenGL::makeCurrent() { - m_lock->lock(); + m_lock.lock(); if (this != MythRenderOpenGL::currentContext()) QGLContext::makeCurrent(); m_lock_level++; @@ -174,7 +173,7 @@ void MythRenderOpenGL::doneCurrent() QGLContext::doneCurrent(); if (m_lock_level < 0) LOG(VB_GENERAL, LOG_ERR, LOC + "Mis-matched calls to makeCurrent()"); - m_lock->unlock(); + m_lock.unlock(); } void MythRenderOpenGL::Release(void) @@ -966,7 +965,6 @@ void MythRenderOpenGL::ResetVars(void) { m_fence = 0; - m_lock = new QMutex(QMutex::Recursive); m_lock_level = 0; m_extensions = QString(); diff --git a/mythtv/libs/libmythui/mythrender_opengl.h b/mythtv/libs/libmythui/mythrender_opengl.h index f5721b6c7a3..818a575290a 100644 --- a/mythtv/libs/libmythui/mythrender_opengl.h +++ b/mythtv/libs/libmythui/mythrender_opengl.h @@ -219,7 +219,7 @@ class MUI_PUBLIC MythRenderOpenGL : public QGLContext, public MythRender GLuint m_fence; // Locking - QMutex *m_lock; + QMutex m_lock; int m_lock_level; // profile