From 2c27c810027d8b01237c0f97359a3fadd6455a45 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 8 Sep 2015 15:57:55 +0100 Subject: tdf#94006 - need an explicit dispose for GLContext's SystemChildWindow. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we would get an explicit ~OpenGLContext - and potentially leave FMR's around for other OGC users, now we treat the other users properly - we need an explicit dispose() to get Window::dispose ordering right. Reviewed-on: https://gerrit.libreoffice.org/18412 Tested-by: Jenkins Reviewed-by: Markus Mohrhard Conflicts: vcl/source/window/openglwin.cxx Change-Id: I5edcbd73399b6db3dbcfb391570f364f9ab0c70d Reviewed-on: https://gerrit.libreoffice.org/18414 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard Reviewed-on: https://gerrit.libreoffice.org/18445 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- avmedia/source/opengl/oglplayer.cxx | 1 + canvas/source/opengl/ogl_spritedevicehelper.cxx | 2 +- include/vcl/opengl/OpenGLContext.hxx | 1 + vcl/source/opengl/OpenGLContext.cxx | 9 +++++++++ vcl/source/window/openglwin.cxx | 10 ++++++++-- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index 7d04807b6b72..7ddaa502e1b9 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -41,6 +41,7 @@ OGLPlayer::~OGLPlayer() { m_xContext->makeCurrent(); gltf_renderer_release(m_pHandle); + m_xContext->dispose(); } releaseInputFiles(); } diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index 091279c27242..e76b86e3f675 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -92,7 +92,7 @@ namespace oglcanvas {} SpriteDeviceHelper::~SpriteDeviceHelper() - {} + { mxContext->dispose(); } void SpriteDeviceHelper::init( vcl::Window& rWindow, SpriteCanvas& rSpriteCanvas, diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index 88e9e71c5fa4..98f9c61079d2 100644 --- a/include/vcl/opengl/OpenGLContext.hxx +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -175,6 +175,7 @@ public: ~OpenGLContext(); void acquire() { mnRefCount++; } void release() { if ( --mnRefCount == 0 ) delete this; } + void dispose(); void requestLegacyContext(); void requestSingleBufferedRendering(); diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 3b70641433e6..ea9664e43e1f 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -112,6 +112,13 @@ OpenGLContext::~OpenGLContext() assert (mnRefCount == 1); } +// release associated child-window if we have one +void OpenGLContext::dispose() +{ + reset(); + m_pChildWindow.disposeAndClear(); +} + rtl::Reference OpenGLContext::Create() { return rtl::Reference(new OpenGLContext); @@ -1283,6 +1290,7 @@ void OpenGLContext::reset() wglMakeCurrent(NULL, NULL); wglDeleteContext( m_aGLWin.hRC ); ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC ); + m_aGLWin.hRC = 0; } #elif defined( MACOSX ) OpenGLWrapper::resetCurrent(); @@ -1304,6 +1312,7 @@ void OpenGLContext::reset() if (mbPixmap && m_aGLWin.glPix != None) glXDestroyPixmap(m_aGLWin.dpy, m_aGLWin.glPix); + m_aGLWin.ctx = 0; } #endif } diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx index 37d1ea5b18e6..9af4c0ff399b 100644 --- a/vcl/source/window/openglwin.cxx +++ b/vcl/source/window/openglwin.cxx @@ -15,8 +15,8 @@ class OpenGLWindowImpl { public: - OpenGLWindowImpl(vcl::Window* pWindow); - ~OpenGLWindowImpl() { mxChildWindow.disposeAndClear(); } + explicit OpenGLWindowImpl(vcl::Window* pWindow); + ~OpenGLWindowImpl(); OpenGLContext& getContext() { return *mxContext.get(); } private: rtl::Reference mxContext; @@ -33,6 +33,12 @@ OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow) pWindow->SetMouseTransparent(false); } +OpenGLWindowImpl::~OpenGLWindowImpl() +{ + mxContext->dispose(); + mxChildWindow.disposeAndClear(); +} + OpenGLWindow::OpenGLWindow(vcl::Window* pParent): Window(pParent, 0), mxImpl(new OpenGLWindowImpl(this)), -- cgit v1.2.3