Moved clear_screen to CVideo and made use of it instead of calling sdl:🪟:fill directly

Should fix nullptr access violations in the tests.
This commit is contained in:
Charles Dang 2017-05-27 11:42:14 +11:00
parent 4d28f268bf
commit 762db98da1
7 changed files with 15 additions and 14 deletions

View file

@ -2468,11 +2468,6 @@ const map_labels& display::labels() const
return *map_labels_;
}
void display::clear_screen()
{
screen_.get_window()->fill(0, 0, 0, 255);
}
const SDL_Rect& display::get_clip_rect()
{
return map_area();

View file

@ -635,10 +635,6 @@ protected:
/// map of hexes where only one unit should be drawn, the one identified by the associated id string
exclusive_unit_draw_requests_t exclusive_unit_draw_requests_;
/** Clear the screen contents */
void clear_screen();
/**
* Called near the beginning of each draw() call.
* Derived classes can use this to add extra actions before redrawing

View file

@ -59,7 +59,7 @@ editor_display::editor_display(editor_controller& controller, CVideo& video, rep
, brush_locations_()
, controller_(controller)
{
clear_screen();
video.clear_screen();
}
void editor_display::add_brush_loc(const map_location& hex)

View file

@ -83,7 +83,7 @@ game_display::game_display(game_board& board, CVideo& video, std::weak_ptr<wb::m
needs_rebuild_(false)
{
replace_overlay_map(&overlay_map_);
clear_screen();
video.clear_screen();
}
game_display* game_display::create_dummy_display(CVideo& video)

View file

@ -273,9 +273,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
const bool is_victory = get_end_level_data_const().is_victory;
if(gamestate().gamedata_.phase() <= game_data::PRESTART) {
if(sdl::window* window = gui_->video().get_window()) {
window->fill(0, 0, 0, 255);
}
gui_->video().clear_screen();
}
ai_testing::log_game_end();

View file

@ -328,6 +328,15 @@ void CVideo::set_window_icon(surface& icon)
window->set_icon(icon);
}
void CVideo::clear_screen()
{
if(!window) {
return;
}
window->fill(0, 0, 0, 255);
}
sdl::window *CVideo::get_window()
{
return window.get();

View file

@ -155,6 +155,9 @@ public:
*/
void set_window_icon(surface& icon);
/** Clear the screen contents */
void clear_screen();
sdl::window *get_window();
/**