Skip to content

Commit

Permalink
Eliminate memory leak in MythRenderOpenGL
Browse files Browse the repository at this point in the history
In commit 07c54f0
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.

Refs #11660

Signed-off-by: Paul Harrison <pharrison@mythtv.org>
  • Loading branch information
garybuhrmaster authored and Paul Harrison committed Jul 13, 2013
1 parent 07c54f0 commit cd314dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -104,22 +104,21 @@ 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();
}

MythRenderOpenGL::~MythRenderOpenGL()
{
delete m_lock;
}

void MythRenderOpenGL::Init(void)
Expand Down Expand Up @@ -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++;
Expand All @@ -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)
Expand Down Expand Up @@ -966,7 +965,6 @@ void MythRenderOpenGL::ResetVars(void)
{
m_fence = 0;

m_lock = new QMutex(QMutex::Recursive);
m_lock_level = 0;

m_extensions = QString();
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -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
Expand Down

0 comments on commit cd314dc

Please sign in to comment.