diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-01-20 04:12:18 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-01-20 12:03:57 +0100 |
commit | 145ad1964389d363e389490be4b9acad1b6b7b99 (patch) | |
tree | 907fc0f38489d7202e7d0707f69a648b6cf699b9 /vcl/source | |
parent | 99f809c7eb0a2298f9c0044aeabdfc1bb72e2287 (diff) |
some debug code for finding leaked OpenGLContexts
Change-Id: I10e8c344ae6aa2e0a4ef562154f57e2070c70e2f
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/svdata.cxx | 6 | ||||
-rw-r--r-- | vcl/source/app/svmain.cxx | 6 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 21 |
3 files changed, 33 insertions, 0 deletions
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index c539a7637866..155b5cc0ba3c 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -130,7 +130,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 8ae359276b23..c0979a651892 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -444,7 +444,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 32d2c28a2cd7..d2372494f970 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() { |