summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-01-20 04:12:18 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-01-28 14:13:15 +0000
commitd2819f2f47f8a98e0ee58242d9a2b54fca383add (patch)
treee4ac8e026c730787d940a9cf963c7becc19fb65b /vcl
parente471f3861bda5575742eac3f1d9747108e5e8e7a (diff)
some debug code for finding leaked OpenGLContexts
Change-Id: I10e8c344ae6aa2e0a4ef562154f57e2070c70e2f Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/opengl/gdiimpl.cxx16
-rw-r--r--vcl/source/app/svdata.cxx6
-rw-r--r--vcl/source/app/svmain.cxx6
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx21
4 files changed, 49 insertions, 0 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 13bfca963b87..519837589cdd 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -78,7 +78,11 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
{
if( mpContext->isInitialized() )
return true;
+#ifdef DBG_UTIL
+ mpContext->DeRef(this);
+#else
mpContext->DeRef();
+#endif
}
@@ -92,7 +96,13 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
}
if( pContext )
+ {
+#ifdef DBG_UTIL
+ pContext->AddRef(this);
+#else
pContext->AddRef();
+#endif
+ }
else
pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
@@ -103,7 +113,13 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
bool OpenGLSalGraphicsImpl::ReleaseContext()
{
if( mpContext )
+ {
+#ifdef DBG_UTIL
+ mpContext->DeRef(this);
+#else
mpContext->DeRef();
+#endif
+ }
mpContext = NULL;
return true;
}
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 1485305166ee..d8934d9d9c0b 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -139,7 +139,13 @@ vcl::Window* ImplGetDefaultWindow()
// Add a reference to the default context so it never gets deleted
OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
if( pContext )
+ {
+#ifdef DBG_UTIL
+ pContext->AddRef(NULL);
+#else
pContext->AddRef();
+#endif
+ }
}
Application::GetSolarMutex().release();
}
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 2fc122c35d56..90bca1f7cb1c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -453,7 +453,13 @@ void DeInitVCL()
{
OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
if( pContext )
+ {
+#ifdef DBG_UTIL
+ pContext->DeRef(NULL);
+#else
pContext->DeRef();
+#endif
+ }
delete pSVData->mpDefaultWin;
pSVData->mpDefaultWin = NULL;
}
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 5cccd73bc78a..6c085fb5646e 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -103,6 +103,26 @@ OpenGLContext::~OpenGLContext()
pSVData->maGDIData.mpLastContext = mpPrevContext;
}
+#ifdef DBG_UTIL
+void OpenGLContext::AddRef(SalGraphicsImpl* pImpl)
+{
+ assert(mnRefCount > 0);
+ mnRefCount++;
+
+ maParents.insert(pImpl);
+}
+
+void OpenGLContext::DeRef(SalGraphicsImpl* pImpl)
+{
+ assert(mnRefCount > 0);
+ if( --mnRefCount == 0 )
+ delete this;
+
+ auto it = maParents.find(pImpl);
+ if(it != maParents.end())
+ maParents.erase(it);
+}
+#else
void OpenGLContext::AddRef()
{
assert(mnRefCount > 0);
@@ -115,6 +135,7 @@ void OpenGLContext::DeRef()
if( --mnRefCount == 0 )
delete this;
}
+#endif
void OpenGLContext::requestLegacyContext()
{