shithub: cstory

Download patch

ref: 2feba10654912a5a9a581382fc39bf790d04f20f
parent: 65e7164c42bb0ace6572e5ba893a3d2c856d1ef9
author: Gabriel Ravier <gabravier@gmail.com>
date: Sat Apr 11 21:00:44 EDT 2020

Backends/Rendering/SDLSurface: Invert `if` and use `!= NULL` instead of implicit conversion to `bool`

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>

--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -58,13 +58,8 @@
 		}
 
 		window_sdlsurface = SDL_GetWindowSurface(window);
-		if (!window_sdlsurface)
+		if (window_sdlsurface != NULL)
 		{
-			std::string error_message = std::string("Could not get SDL surface of the window: ") + SDL_GetError();
-			Backend_ShowMessageBox("Fatal error (SDLSurface rendering backend)", error_message.c_str());
-		}
-		else
-		{
 			framebuffer.sdlsurface = SDL_CreateRGBSurfaceWithFormat(0, window_sdlsurface->w, window_sdlsurface->h, 0, SDL_PIXELFORMAT_RGB24);
 
 			if (framebuffer.sdlsurface != NULL)
@@ -75,6 +70,11 @@
 			}
 
 			std::string error_message = std::string("Could not create framebuffer surface: ") + SDL_GetError();
+			Backend_ShowMessageBox("Fatal error (SDLSurface rendering backend)", error_message.c_str());
+		}
+		else
+		{
+			std::string error_message = std::string("Could not get SDL surface of the window: ") + SDL_GetError();
 			Backend_ShowMessageBox("Fatal error (SDLSurface rendering backend)", error_message.c_str());
 		}