|
@@ -89,10 +89,8 @@
|
|
|
@end
|
|
|
|
|
|
|
|
|
-/* Display a Cocoa message box */
|
|
|
-int
|
|
|
-Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|
|
-{ @autoreleasepool
|
|
|
+static void
|
|
|
+Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue)
|
|
|
{
|
|
|
Cocoa_RegisterApp();
|
|
|
|
|
@@ -133,11 +131,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|
|
|
|
|
SDLMessageBoxPresenter* presenter = [[[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window] autorelease];
|
|
|
|
|
|
- [presenter performSelectorOnMainThread:@selector(showAlert:)
|
|
|
- withObject:alert
|
|
|
- waitUntilDone:YES];
|
|
|
+ [presenter showAlert:alert];
|
|
|
|
|
|
- int returnValue = 0;
|
|
|
NSInteger clicked = presenter->clicked;
|
|
|
if (clicked >= NSAlertFirstButtonReturn) {
|
|
|
clicked -= NSAlertFirstButtonReturn;
|
|
@@ -145,10 +140,24 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|
|
clicked = messageboxdata->numbuttons - 1 - clicked;
|
|
|
}
|
|
|
*buttonid = buttons[clicked].buttonid;
|
|
|
+ *returnValue = 0;
|
|
|
} else {
|
|
|
- returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
|
|
|
+ *returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
+/* Display a Cocoa message box */
|
|
|
+int
|
|
|
+Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|
|
+{ @autoreleasepool
|
|
|
+{
|
|
|
+ __block int returnValue = 0;
|
|
|
+
|
|
|
+ if ([NSThread isMainThread]) {
|
|
|
+ Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue);
|
|
|
+ } else {
|
|
|
+ dispatch_sync(dispatch_get_main_queue(), ^{ Cocoa_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); });
|
|
|
+ }
|
|
|
return returnValue;
|
|
|
}}
|
|
|
|