Re-enabled other messagebox tests, moved the SDL_Init() call as late as possible to show the circumstances where it's needed.
authorSam Lantinga <slouken@libsdl.org>
Sun, 14 Jul 2013 12:16:10 -0700
changeset 7458 648067e9073a
parent 7457 8e6dfbc8ac6b
child 7459 7c6bd424f819
Re-enabled other messagebox tests, moved the SDL_Init() call as late as possible to show the circumstances where it's needed.
test/testmessage.c
--- a/test/testmessage.c	Sun Jul 14 11:58:57 2013 -0700
+++ b/test/testmessage.c	Sun Jul 14 12:16:10 2013 -0700
@@ -60,7 +60,7 @@
         data.message = "This is a custom messagebox from a background thread.";
     }
 
-    success =SDL_ShowMessageBox(&data, &button);
+    success = SDL_ShowMessageBox(&data, &button);
     if (success == -1) {
         printf("Error Presenting MessageBox: %s\n", SDL_GetError());
         if (eventNumber) {
@@ -88,13 +88,6 @@
 {
     int success;
 
-    /* Load the SDL library */
-    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
-        return (1);
-    }
-
-#if 0
     success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                 "Simple MessageBox",
                 "This is a simple error MessageBox",
@@ -135,7 +128,16 @@
 
     button_messagebox(NULL);
 
-    /* Test showing a message box from a background thread */
+    /* Test showing a message box from a background thread.
+
+       On Mac OS X, the video subsystem needs to be initialized for this
+       to work, since the message box events are dispatched by the Cocoa
+       subsystem on the main thread.
+     */
+    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+        fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
+        return (1);
+    }
     {
         int status = 0;
         SDL_Event event;
@@ -153,7 +155,6 @@
 
         printf("Message box thread return %i\n", status);
     }
-#endif
 
     /* Test showing a message box with a parent window */
     {