From Ralf Habacker, fix to memory leak in GraphicsWindowWin32.cpp. Merged from OSG-2.8 branch using svn command:

svn merge -r 9726:9727 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/branches/OpenSceneGraph-2.8
This commit is contained in:
Robert Osfield 2009-02-09 21:42:45 +00:00
parent 0adcfda07a
commit abe28296ee

View File

@ -1172,6 +1172,20 @@ bool GraphicsWindowWin32::createWindow()
return false; 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); Win32WindowingSystem::getInterface()->registerWindow(_hwnd, this);
return true; return true;
} }
@ -1209,37 +1223,23 @@ bool GraphicsWindowWin32::setWindow( HWND handle )
// Check if we must set the pixel format of the inherited window // 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());
{ ::ReleaseDC(_hwnd, _hdc);
reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to set the inherited window pixel format", _traits->screenNum, ::GetLastError()); _hdc = 0;
_hdc = 0; _hwnd = 0;
_hwnd = 0; return false;
return false;
}
} }
else
_hglrc = ::wglCreateContext(_hdc);
if (_hglrc==0)
{ {
// reportErrorForScreen("GraphicsWindowWin32::setWindow() - Unable to create OpenGL rendering context", _traits->screenNum, ::GetLastError());
// Create the OpenGL rendering context associated with this window ::ReleaseDC(_hwnd, _hdc);
// _hdc = 0;
if (!setPixelFormat()) _hwnd = 0;
{ return false;
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;
}
} }
if (!registerWindowProcedure()) if (!registerWindowProcedure())
@ -1566,17 +1566,6 @@ bool GraphicsWindowWin32::setPixelFormat()
return false; 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; return true;
} }