diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-04-02 03:31:38 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-04-08 04:38:20 +0200 |
commit | b458c16a431010712b0d5e18b125a9ec897372c9 (patch) | |
tree | df3740fbb1a74da836df48a4f8bff0e6c1202fe4 /vcl | |
parent | 8325b7b49ec095349571efb17fe0d520ab67f897 (diff) |
fix crash when passing external Window to OpenGLContext::init
The external window is not controlled by OpenGLContext so it is not
allowed to delete the window
Change-Id: Id2c79a3612cc875fd94b8cd1206b30af2f185875
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index b60e6f58739a..304d9f467dff 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -14,6 +14,7 @@ using namespace com::sun::star; OpenGLContext::OpenGLContext(): + mpWindow(NULL), mbInitialized(false) { } @@ -319,13 +320,15 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ ) bool OpenGLContext::init( Window* pParent ) { - m_pWindow.reset(pParent ? pParent : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)); if(mbInitialized) return true; + m_pWindow.reset(pParent ? NULL : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)); + mpWindow = pParent ? pParent : m_pWindow.get(); SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start"); initWindow(); - m_pWindow->setPosSizePixel(0,0,0,0); + if(m_pWindow) + m_pWindow->setPosSizePixel(0,0,0,0); m_aGLWin.Width = 0; m_aGLWin.Height = 0; @@ -396,10 +399,10 @@ bool OpenGLContext::init( Window* pParent ) double nGLXVersion = 0; if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) ) nGLXVersion = glxMajor + 0.1*glxMinor; - SAL_INFO("vcl.opengl", "available GLX version: %f", nGLXVersion); + SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion); m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS ); - SAL_INFO("vcl.opengl", "available GL extensions: %s", m_aGLWin.GLExtensions); + SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions); if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) ) { @@ -451,7 +454,8 @@ bool OpenGLContext::init( Window* pParent ) void OpenGLContext::setWinSize(const Size& rSize) { - m_pWindow->SetSizePixel(rSize); + if(m_pWindow) + m_pWindow->SetSizePixel(rSize); m_pChildWindow->SetSizePixel(rSize); } @@ -464,11 +468,11 @@ GLWindow& OpenGLContext::getOpenGLWindow() bool OpenGLContext::initWindow() { - const SystemEnvData* sysData(m_pWindow->GetSystemData()); + const SystemEnvData* sysData(mpWindow->GetSystemData()); m_aGLWin.hWnd = sysData->hWnd; SystemWindowData winData; winData.nSize = sizeof(winData); - m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, sal_False)); + m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, sal_False)); if( m_pChildWindow ) { @@ -502,14 +506,13 @@ void initOpenGLFunctionPointers() glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib"); - } } bool OpenGLContext::initWindow() { - const SystemEnvData* sysData(m_pWindow->GetSystemData()); + const SystemEnvData* sysData(mpWindow->GetSystemData()); m_aGLWin.dpy = reinterpret_cast<Display*>(sysData->pDisplay); @@ -518,7 +521,7 @@ bool OpenGLContext::initWindow() m_aGLWin.win = sysData->aWindow; - SAL_INFO("vcl.opengl", "parent window: %d", m_aGLWin.win); + SAL_INFO("vcl.opengl", "parent window: " << m_aGLWin.win); XWindowAttributes xattr; XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xattr ); @@ -581,9 +584,9 @@ bool OpenGLContext::initWindow() { SystemWindowData winData; winData.nSize = sizeof(winData); - SAL_INFO("vcl.opengl", "using VisualID %08X", vi->visualid); + SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid); winData.pVisual = (void*)(vi->visual); - m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, false)); + m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, false)); pChildSysData = m_pChildWindow->GetSystemData(); } @@ -600,7 +603,7 @@ bool OpenGLContext::initWindow() m_aGLWin.win = pChildSysData->aWindow; m_aGLWin.vi = vi; m_aGLWin.GLXExtensions = glXQueryExtensionsString( m_aGLWin.dpy, m_aGLWin.screen ); - SAL_INFO("vcl.opengl", "available GLX extensions: %s", m_aGLWin.GLXExtensions); + SAL_INFO("vcl.opengl", "available GLX extensions: " << m_aGLWin.GLXExtensions); return true; } |