From Ralf Habacker, "on win32 there is a memory leak in recent svn code in GraphicsWindowWin32.cpp.
in bool GraphicsWindowWin32::setWindow( HWND handle )
there is the following if/else statement
if (_traits.valid() && _traits->setInheritedWindowPixelFormat)
....
else
setPixelFormat()
_hglrc = ::wglCreateContext(...) [1]
setPixelFormat() calls wglCreateContext() and saves the result into _hglrc which is overwritten by a second call to wglCreateContext() call at [1]
The same behavior occurs in bool Win32WindowingSystem::getSampleOpenGLContext( OpenGLContext& context, HDC windowHDC, int windowOriginX, int windowOriginY ).
The solution for this issue is to move the wglCreateContext() out of setPixelFormat() and to place it into the caller which is done to the appended file
"
This commit is contained in:
@@ -1172,6 +1172,20 @@ bool GraphicsWindowWin32::createWindow()
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Create the OpenGL rendering context associated with this window
|
||||
//
|
||||
|
||||
_hglrc = ::wglCreateContext(_hdc);
|
||||
if (_hglrc==0)
|
||||
{
|
||||
reportErrorForScreen("GraphicsWindowWin32::createWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError());
|
||||
::ReleaseDC(_hwnd, _hdc);
|
||||
_hdc = 0;
|
||||
destroyWindow();
|
||||
return false;
|
||||
}
|
||||
|
||||
Win32WindowingSystem::getInterface()->registerWindow(_hwnd, this);
|
||||
return true;
|
||||
}
|
||||
@@ -1209,37 +1223,23 @@ bool GraphicsWindowWin32::setWindow( HWND handle )
|
||||
// Check if we must set the pixel format of the inherited window
|
||||
//
|
||||
|
||||
if (_traits.valid() && _traits->setInheritedWindowPixelFormat)
|
||||
if (!setPixelFormat())
|
||||
{
|
||||
if (!setPixelFormat())
|
||||
{
|
||||
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError());
|
||||
_hdc = 0;
|
||||
_hwnd = 0;
|
||||
return false;
|
||||
}
|
||||
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError());
|
||||
::ReleaseDC(_hwnd, _hdc);
|
||||
_hdc = 0;
|
||||
_hwnd = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
_hglrc = ::wglCreateContext(_hdc);
|
||||
if (_hglrc==0)
|
||||
{
|
||||
//
|
||||
// Create the OpenGL rendering context associated with this window
|
||||
//
|
||||
if (!setPixelFormat())
|
||||
{
|
||||
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError());
|
||||
_hdc = 0;
|
||||
_hwnd = 0;
|
||||
return false;
|
||||
}
|
||||
_hglrc = ::wglCreateContext(_hdc);
|
||||
if (_hglrc==0)
|
||||
{
|
||||
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError());
|
||||
::ReleaseDC(_hwnd, _hdc);
|
||||
_hdc = 0;
|
||||
_hwnd = 0;
|
||||
return false;
|
||||
}
|
||||
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError());
|
||||
::ReleaseDC(_hwnd, _hdc);
|
||||
_hdc = 0;
|
||||
_hwnd = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!registerWindowProcedure())
|
||||
@@ -1566,17 +1566,6 @@ bool GraphicsWindowWin32::setPixelFormat()
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Create the OpenGL rendering context associated with this window
|
||||
//
|
||||
|
||||
_hglrc = ::wglCreateContext(_hdc);
|
||||
if (_hglrc==0)
|
||||
{
|
||||
reportErrorForScreen("GraphicsWindowWin32::setPixelFormat() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user