File: 02_sdl_error_checks.patch

package info (click to toggle)
mousetrap 1.0c-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,164 kB
  • sloc: sh: 2,353; cpp: 899; makefile: 52
file content (24 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Description: Improve some error checking on SDL_Init and SDL_SetVideoMode.
Author: Barry deFreese <bdefreese@debian.org>
Index: mousetrap-1.0c/src/mousetrap.cpp
===================================================================
--- mousetrap-1.0c.orig/src/mousetrap.cpp	2013-08-01 20:50:12.850774261 -0400
+++ mousetrap-1.0c/src/mousetrap.cpp	2013-08-01 20:54:22.756013474 -0400
@@ -346,13 +346,16 @@
     srand( (unsigned)time( NULL ) );
 
     /* initialize SDL. */
-    SDL_Init(SDL_INIT_VIDEO);
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
+        printf("Failed to initialized SDL: %s.\n", SDL_GetError());
 
     /* set the title bar */
     SDL_WM_SetCaption("MouseTrap", "MouseTrap");
 
     /* create window */
     screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+    if (screen == NULL)
+        printf("Failed to set video mode: %s.\n", SDL_GetError());
 
     /* load sprite */
     temp   = loadImage((char *)"data/images/sprite.bmp");