Fixes bug #24138 and disables SDL_PumpEvent() in grid.cpp
This removes the usage of the display::get_singleton() in the event handling code since it may cause incorrect behaviour (crash) when the singleton has been incorrectly set to null. This also removes SDL_PumpEvents() from grid.cpp the rendering code should not be directly interacting with the event handling and it's causing instabilities.
This commit is contained in:
parent
3a5b122325
commit
36456df46f
5 changed files with 11 additions and 15 deletions
|
@ -551,7 +551,7 @@ void peek_for_resize()
|
|||
for (int i = 0; i < num; i++) {
|
||||
if (events[i].type == SDL_WINDOWEVENT &&
|
||||
events[i].window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
display::get_singleton()->video().update_framebuffer();
|
||||
update_framebuffer();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#include "gui/auxiliary/layout_exception.hpp"
|
||||
#include "gui/widgets/control.hpp"
|
||||
#include "utils/foreach.tpp"
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
#include "events.hpp"
|
||||
#endif
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
@ -920,9 +917,8 @@ void tgrid::impl_draw_children(surface& frame_buffer)
|
|||
* Without the call when resizing larger a black area of remains, this is
|
||||
* the area not used for resizing the screen, this call `fixes' that.
|
||||
*/
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_PumpEvents();
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
events::peek_for_resize();
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -962,9 +958,8 @@ tgrid::impl_draw_children(surface& frame_buffer, int x_offset, int y_offset)
|
|||
* Without the call when resizing larger a black area of remains, this is
|
||||
* the area not used for resizing the screen, this call `fixes' that.
|
||||
*/
|
||||
#if !SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_PumpEvents();
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
events::peek_for_resize();
|
||||
#endif
|
||||
|
||||
assert(get_visible() == twidget::tvisible::visible);
|
||||
|
|
|
@ -211,7 +211,7 @@ void loadscreen::draw_screen(const std::string &text)
|
|||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
if (ev.type == SDL_WINDOWEVENT &&
|
||||
ev.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
display::get_singleton()->video().update_framebuffer();
|
||||
update_framebuffer();
|
||||
}
|
||||
if (ev.type == SDL_WINDOWEVENT &&
|
||||
(ev.window.event == SDL_WINDOWEVENT_RESIZED ||
|
||||
|
|
|
@ -533,7 +533,7 @@ int CVideo::modePossible( int x, int y, int bits_per_pixel, int flags, bool curr
|
|||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
|
||||
void CVideo::update_framebuffer()
|
||||
void update_framebuffer()
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
|
|
@ -49,6 +49,12 @@ GPU_Target *get_render_target();
|
|||
|
||||
surface display_format_alpha(surface surf);
|
||||
surface& get_video_surface();
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
//this needs to be invoked immediately after a resize event or the game will crash.
|
||||
void update_framebuffer();
|
||||
#endif
|
||||
|
||||
|
||||
SDL_Rect screen_area();
|
||||
|
||||
|
||||
|
@ -75,11 +81,6 @@ class CVideo : private boost::noncopyable {
|
|||
int modePossible( int x, int y, int bits_per_pixel, int flags, bool current_screen_optimal=false);
|
||||
int setMode( int x, int y, int bits_per_pixel, int flags );
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
//this needs to be invoked immediately after a resize event or the game will crash.
|
||||
void update_framebuffer();
|
||||
#endif
|
||||
|
||||
//did the mode change, since the last call to the modeChanged() method?
|
||||
bool modeChanged();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue