comparison src/video/cocoa/SDL_cocoavideo.m @ 3647:c5925cd41955

First pass at Ryan's assertion code, minor tweaks to come.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 13 Jan 2010 06:47:17 +0000
parents 59ff7a2beb57
children 2d17445190f6
comparison
equal deleted inserted replaced
3646:88235d40b135 3647:c5925cd41955
133 Cocoa_QuitModes(_this); 133 Cocoa_QuitModes(_this);
134 Cocoa_QuitKeyboard(_this); 134 Cocoa_QuitKeyboard(_this);
135 Cocoa_QuitMouse(_this); 135 Cocoa_QuitMouse(_this);
136 } 136 }
137 137
138
139 /*
140 * Mac OS X assertion support.
141 *
142 * This doesn't really have aything to do with the interfaces of the SDL video
143 * subsystem, but we need to stuff this into an Objective-C source code file.
144 */
145
146 SDL_assert_state
147 SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
148 {
149 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
150
151 NSString *msg = [NSString stringWithFormat:
152 @"Assertion failure at %s (%s:%d), triggered %u time%s:\n '%s'",
153 data->function, data->filename, data->linenum,
154 data->trigger_count, (data->trigger_count == 1) ? "" : "s",
155 data->condition];
156
157 NSLog(msg);
158
159 /*
160 * !!! FIXME: this code needs to deal with fullscreen modes:
161 * !!! FIXME: reset to default desktop, runModal, reset to current?
162 */
163
164 NSAlert* alert = [[NSAlert alloc] init];
165 [alert setAlertStyle:NSCriticalAlertStyle];
166 [alert setMessageText:msg];
167 [alert addButtonWithTitle:@"Retry"];
168 [alert addButtonWithTitle:@"Break"];
169 [alert addButtonWithTitle:@"Abort"];
170 [alert addButtonWithTitle:@"Ignore"];
171 [alert addButtonWithTitle:@"Always Ignore"];
172 const NSInteger clicked = [alert runModal];
173 [pool release];
174 return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
175 }
176
138 /* vim: set ts=4 sw=4 expandtab: */ 177 /* vim: set ts=4 sw=4 expandtab: */
178