Skip to content

Commit

Permalink
Merge pull request #76000 from andrei8l/ui_adaptor-shutdown
Browse files Browse the repository at this point in the history
ui_adaptor: don't invalidate uis below when exiting game
  • Loading branch information
akrieger authored Aug 28, 2024
2 parents 72a0ea0 + 78374c6 commit aa7f6e2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ncurses_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void catacurses::erase()

void catacurses::endwin()
{
ui_manager::reset();
return curses_check_result( ::endwin(), OK, "endwin" );
}

Expand Down
1 change: 1 addition & 0 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3771,6 +3771,7 @@ void catacurses::endwin()
font.reset();
map_font.reset();
overmap_font.reset();
ui_manager::reset();
WinDestroy();
}

Expand Down
15 changes: 15 additions & 0 deletions src/ui_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ ui_adaptor::ui_adaptor( ui_adaptor::debug_message_ui ) : is_imgui( false ),

ui_adaptor::~ui_adaptor()
{
if( is_shutting_down ) {
return;
}
if( is_debug_message_ui ) {
cata_assert( showing_debug_message );
showing_debug_message = false;
Expand Down Expand Up @@ -306,6 +309,11 @@ void ui_adaptor::reset()
position( point_zero, point_zero );
}

void ui_adaptor::shutdown()
{
is_shutting_down = true;
}

void ui_adaptor::invalidate( const rectangle<point> &rect, const bool reenable_uis_below )
{
if( rect.p_min.x >= rect.p_max.x || rect.p_min.y >= rect.p_max.y ) {
Expand Down Expand Up @@ -523,4 +531,11 @@ void invalidate_all_ui_adaptors()
adaptor.invalidate_ui();
}
}

void reset()
{
for( ui_adaptor &adaptor : ui_stack ) {
adaptor.shutdown();
}
}
} // namespace ui_manager
4 changes: 4 additions & 0 deletions src/ui_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class ui_adaptor
**/
void reset();

void shutdown();

/* See the `ui_manager` namespace */
static void invalidate( const rectangle<point> &rect, bool reenable_uis_below );
static bool has_imgui();
Expand All @@ -248,6 +250,7 @@ class ui_adaptor

bool disabling_uis_below;
bool is_debug_message_ui;
bool is_shutting_down = false;

mutable bool invalidated;
mutable bool deferred_resize;
Expand Down Expand Up @@ -292,6 +295,7 @@ void redraw_invalidated();
**/
void screen_resized();
void invalidate_all_ui_adaptors();
void reset();
} // namespace ui_manager

#endif // CATA_SRC_UI_MANAGER_H
1 change: 1 addition & 0 deletions src/wincurse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ std::optional<tripoint> input_context::get_coordinates( const catacurses::window
// Ends the terminal, destroy everything
void catacurses::endwin()
{
ui_manager::reset();
DeleteObject( font );
WinDestroy();
// Unload it
Expand Down

0 comments on commit aa7f6e2

Please sign in to comment.