diff options
author | rubidium <rubidium@openttd.org> | 2006-12-03 17:42:56 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-03 17:42:56 +0000 |
commit | 32ac800be60811ca433dc59a63e8aec44e4853d3 (patch) | |
tree | 72ffedf306e22a23e8271d6191eddefb7710a910 | |
parent | f3358b9813bbc0d630dc05e3ab24a757f367d954 (diff) | |
download | openttd-32ac800be60811ca433dc59a63e8aec44e4853d3.tar.xz |
(svn r7332) -Fix: segmentation fault, discovered by ln-, in the SDL video driver when one goes to fullscreen and there are no suitable resolutions.
-rw-r--r-- | gfx.c | 9 | ||||
-rw-r--r-- | video/sdl_v.c | 2 |
2 files changed, 9 insertions, 2 deletions
@@ -15,6 +15,7 @@ #include "table/control_codes.h" #include "fontcache.h" #include "genworld.h" +#include "debug.h" #ifdef _DEBUG bool _dbg_screen_rect; @@ -1998,7 +1999,13 @@ bool ChangeResInGame(int w, int h) _video_driver->change_resolution(w, h); } -void ToggleFullScreen(bool fs) {_video_driver->toggle_fullscreen(fs);} +void ToggleFullScreen(bool fs) +{ + _video_driver->toggle_fullscreen(fs); + if (_fullscreen != fs && _num_resolutions == 0) { + DEBUG(misc, 0) ("Could not find a suitable fullscreen resolution."); + } +} static int CDECL compare_res(const void *pa, const void *pb) { diff --git a/video/sdl_v.c b/video/sdl_v.c index 8e997a857..b0a25a9d7 100644 --- a/video/sdl_v.c +++ b/video/sdl_v.c @@ -495,7 +495,7 @@ static void SdlVideoFullScreen(bool full_screen) { _fullscreen = full_screen; GetVideoModes(); // get the list of available video modes - if (!_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1])) { + if (_num_resolutions == 0 || !_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1])) { // switching resolution failed, put back full_screen to original status _fullscreen ^= true; } |