mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
GetWindowSize: Initialize out values if GetRendererOutput fails
Issue #870 showed one of the problems that this game has, namely that it only sometimes checks SDL return values, and did not do so in this case. Part of the cause of #870 is that Screen::GetWindowSize does not check the return value of SDL_GetRendererOutputSize, so when that function fails (as in the case where m_renderer is NULL and does not exist), it does not initialize the out values, so it ends up writing uninitialized values to the save files. We need to make sure every function's return value is checked, not just SDL functions, but that will have to be done later.
This commit is contained in:
@@ -253,7 +253,13 @@ void Screen::ResizeToNearestMultiple(void)
|
|||||||
|
|
||||||
void Screen::GetWindowSize(int* x, int* y)
|
void Screen::GetWindowSize(int* x, int* y)
|
||||||
{
|
{
|
||||||
SDL_GetRendererOutputSize(m_renderer, x, y);
|
if (SDL_GetRendererOutputSize(m_renderer, x, y) != 0)
|
||||||
|
{
|
||||||
|
vlog_error("Could not get window size: %s", SDL_GetError());
|
||||||
|
/* Initialize to safe defaults */
|
||||||
|
*x = SCREEN_WIDTH_PIXELS;
|
||||||
|
*y = SCREEN_HEIGHT_PIXELS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
||||||
|
|||||||
Reference in New Issue
Block a user