Commit b707a3b7 by apatrick@chromium.org

Added runtime checks for GetClientRect errors.

I noticed that if the window handle is invalid, the resulting rect will be uninitialized. This change makes it fail immediately. Review URL: http://codereview.appspot.com/2009042 git-svn-id: https://angleproject.googlecode.com/svn/trunk@386 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 32cfaf4b
...@@ -92,7 +92,12 @@ void Surface::resetSwapChain() ...@@ -92,7 +92,12 @@ void Surface::resetSwapChain()
presentParameters.Windowed = TRUE; presentParameters.Windowed = TRUE;
RECT windowRect; RECT windowRect;
GetClientRect(getWindowHandle(), &windowRect); if (!GetClientRect(getWindowHandle(), &windowRect))
{
ASSERT(false);
return;
}
presentParameters.BackBufferWidth = windowRect.right - windowRect.left; presentParameters.BackBufferWidth = windowRect.right - windowRect.left;
presentParameters.BackBufferHeight = windowRect.bottom - windowRect.top; presentParameters.BackBufferHeight = windowRect.bottom - windowRect.top;
...@@ -308,7 +313,12 @@ void Surface::releaseRecordedState(IDirect3DDevice9 *device) ...@@ -308,7 +313,12 @@ void Surface::releaseRecordedState(IDirect3DDevice9 *device)
bool Surface::checkForWindowResize() bool Surface::checkForWindowResize()
{ {
RECT client; RECT client;
GetClientRect(getWindowHandle(), &client); if (!GetClientRect(getWindowHandle(), &client))
{
ASSERT(false);
return false;
}
if (getWidth() != client.right - client.left || getHeight() != client.bottom - client.top) if (getWidth() != client.right - client.left || getHeight() != client.bottom - client.top)
{ {
resetSwapChain(); resetSwapChain();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment