Mercurial > sdl-ios-xcode
comparison src/SDL_assert.c @ 3657:eaea59cee6f2
Leave fullscreen mode to pop an assertion dialog
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 13 Jan 2010 08:44:46 +0000 |
parents | f17ea6f49745 |
children | 22b6a0c7ea6e |
comparison
equal
deleted
inserted
replaced
3656:f17ea6f49745 | 3657:eaea59cee6f2 |
---|---|
252 | 252 |
253 | 253 |
254 static SDL_assert_state SDL_PromptAssertion(const SDL_assert_data *data) | 254 static SDL_assert_state SDL_PromptAssertion(const SDL_assert_data *data) |
255 { | 255 { |
256 const char *envr; | 256 const char *envr; |
257 SDL_assert_state state = SDL_ASSERTION_ABORT; | |
258 SDL_WindowID window; | |
257 | 259 |
258 debug_print("\n\n" | 260 debug_print("\n\n" |
259 "Assertion failure at %s (%s:%d), triggered %u time%s:\n" | 261 "Assertion failure at %s (%s:%d), triggered %u time%s:\n" |
260 " '%s'\n" | 262 " '%s'\n" |
261 "\n", | 263 "\n", |
279 } else { | 281 } else { |
280 return SDL_ASSERTION_ABORT; /* oh well. */ | 282 return SDL_ASSERTION_ABORT; /* oh well. */ |
281 } | 283 } |
282 } | 284 } |
283 | 285 |
286 /* Leave fullscreen mode, if possible (scary!) */ | |
287 window = SDL_GetFocusWindow(); | |
288 if (window) { | |
289 if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) { | |
290 SDL_MinimizeWindow(window); | |
291 } else { | |
292 /* No need to mess with the window */ | |
293 window = 0; | |
294 } | |
295 } | |
296 | |
284 /* platform-specific UI... */ | 297 /* platform-specific UI... */ |
285 | 298 |
286 #ifdef _WINDOWS | 299 #ifdef _WINDOWS |
287 return SDL_PromptAssertion_windows(data); | 300 state = SDL_PromptAssertion_windows(data); |
288 | 301 |
289 #elif __APPLE__ | 302 #elif __APPLE__ |
290 /* This has to be done in an Objective-C (*.m) file, so we call out. */ | 303 /* This has to be done in an Objective-C (*.m) file, so we call out. */ |
291 extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *); | 304 extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *); |
292 return SDL_PromptAssertion_cocoa(data); | 305 state = SDL_PromptAssertion_cocoa(data); |
293 | 306 |
294 #elif unix | 307 #else |
295 /* this is a little hacky. */ | 308 /* this is a little hacky. */ |
296 for ( ; ; ) { | 309 for ( ; ; ) { |
297 char buf[32]; | 310 char buf[32]; |
298 fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : "); | 311 fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : "); |
299 fflush(stderr); | 312 fflush(stderr); |
300 if (fgets(buf, sizeof (buf), stdin) == NULL) { | 313 if (fgets(buf, sizeof (buf), stdin) == NULL) { |
301 return SDL_ASSERTION_ABORT; | 314 break; |
302 } | 315 } |
303 | 316 |
304 if (SDL_strcmp(buf, "a") == 0) { | 317 if (SDL_strcmp(buf, "a") == 0) { |
305 return SDL_ASSERTION_ABORT; | 318 state = SDL_ASSERTION_ABORT; |
319 break; | |
306 } else if (SDL_strcmp(envr, "b") == 0) { | 320 } else if (SDL_strcmp(envr, "b") == 0) { |
307 return SDL_ASSERTION_BREAK; | 321 state = SDL_ASSERTION_BREAK; |
322 break; | |
308 } else if (SDL_strcmp(envr, "r") == 0) { | 323 } else if (SDL_strcmp(envr, "r") == 0) { |
309 return SDL_ASSERTION_RETRY; | 324 state = SDL_ASSERTION_RETRY; |
325 break; | |
310 } else if (SDL_strcmp(envr, "i") == 0) { | 326 } else if (SDL_strcmp(envr, "i") == 0) { |
311 return SDL_ASSERTION_IGNORE; | 327 state = SDL_ASSERTION_IGNORE; |
328 break; | |
312 } else if (SDL_strcmp(envr, "A") == 0) { | 329 } else if (SDL_strcmp(envr, "A") == 0) { |
313 return SDL_ASSERTION_ALWAYS_IGNORE; | 330 state = SDL_ASSERTION_ALWAYS_IGNORE; |
314 } | 331 break; |
315 } | 332 } |
316 | 333 } |
317 #else | 334 #endif |
318 #error Please define your platform or set SDL_ASSERT_LEVEL to 0. | 335 |
319 #endif | 336 /* Re-enter fullscreen mode */ |
320 | 337 if (window) { |
321 return SDL_ASSERTION_ABORT; | 338 SDL_RestoreWindow(window); |
339 } | |
340 | |
341 return state; | |
322 } | 342 } |
323 | 343 |
324 | 344 |
325 static SDL_mutex *assertion_mutex = NULL; | 345 static SDL_mutex *assertion_mutex = NULL; |
326 | 346 |