diff options
author | Patric Stout <truebrain@openttd.org> | 2021-02-17 14:06:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 14:06:12 +0100 |
commit | 6de188d0251da7bc7aa7f67bbc81cf87d0a7e78f (patch) | |
tree | cb7d03c8f099feb6287538a472c8f98407c3e6ec /src/video | |
parent | 7bdb2e79ed0c15d6d587fd170190890f5b9fdbb3 (diff) | |
download | openttd-6de188d0251da7bc7aa7f67bbc81cf87d0a7e78f.tar.xz |
Fix 52317bb7: [SDL2] ensure we don't try to blit out of bounds (#8684)
During resizing, there can still be dirty-rects ready to blit based
on the old dimensions. X11 with shared memory enabled crashes if
you try to do this. So, instead, if we resize, reset the dirty-rects.
This is fine, as moments later we mark the whole (new) screen as
dirty anyway.
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/sdl2_v.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 14a8bfd1c..ce6bbc93f 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -351,6 +351,13 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize) _sdl_surface = _sdl_real_surface; } + /* X11 doesn't appreciate it if we invalidate areas outside the window + * if shared memory is enabled (read: it crashes). So, as we might have + * gotten smaller, reset our dirty rects. GameSizeChanged() a bit lower + * will mark the whole screen dirty again anyway, but this time with the + * new dimensions. */ + _num_dirty_rects = 0; + _screen.width = _sdl_surface->w; _screen.height = _sdl_surface->h; _screen.pitch = _sdl_surface->pitch / (bpp / 8); |