Crash-proof the lobby by making lobby gamelist filter updates consistent.
This fixes bug #15636 (and bug #15163 which was the same thing and was not actually fixed before that)
This commit is contained in:
parent
af0d104546
commit
7f7e8676c2
2 changed files with 14 additions and 8 deletions
|
@ -205,7 +205,8 @@ void lobby_info::process_userlist()
|
|||
|
||||
void lobby_info::sync_games_display_status()
|
||||
{
|
||||
DBG_LB << "lobby_info::sync_games_display_status\n";
|
||||
DBG_LB << "lobby_info::sync_games_display_status";
|
||||
DBG_LB << "games_by_id_ size: " << games_by_id_.size();
|
||||
game_info_map::iterator i = games_by_id_.begin();
|
||||
while (i != games_by_id_.end()) {
|
||||
if (i->second->display_status == game_info::DELETED) {
|
||||
|
@ -215,6 +216,8 @@ void lobby_info::sync_games_display_status()
|
|||
++i;
|
||||
}
|
||||
}
|
||||
DBG_LB << " -> " << games_by_id_.size() << "\n";
|
||||
make_games_vector();
|
||||
}
|
||||
|
||||
game_info* lobby_info::get_game_by_id(int id)
|
||||
|
@ -304,23 +307,22 @@ void lobby_info::make_games_vector()
|
|||
foreach (const game_info_map::value_type& v, games_by_id_) {
|
||||
games_.push_back(v.second);
|
||||
}
|
||||
games_visibility_.resize(games_.size());
|
||||
}
|
||||
|
||||
void lobby_info::apply_game_filter()
|
||||
{
|
||||
int i = 0;
|
||||
games_filtered_.clear();
|
||||
games_visibility_.clear();
|
||||
foreach (game_info* g, games_) {
|
||||
game_info& gi = *g;
|
||||
bool show = game_filter_.match(gi);
|
||||
if (game_filter_invert_) {
|
||||
show = !show;
|
||||
}
|
||||
games_visibility_[i] = show;
|
||||
games_visibility_.push_back(show);
|
||||
if (show) {
|
||||
games_filtered_.push_back(&gi);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -572,7 +572,6 @@ void tlobby_main::update_gamelist()
|
|||
gamelistbox_->clear();
|
||||
gamelist_id_at_row_.clear();
|
||||
lobby_info_.make_games_vector();
|
||||
lobby_info_.apply_game_filter();
|
||||
update_gamelist_header();
|
||||
int select_row = -1;
|
||||
for (unsigned i = 0; i < lobby_info_.games().size(); ++i) {
|
||||
|
@ -586,7 +585,6 @@ void tlobby_main::update_gamelist()
|
|||
tgrid* grid = gamelistbox_->get_row_grid(gamelistbox_->get_item_count() - 1);
|
||||
adjust_game_row_contents(game, gamelistbox_->get_item_count() - 1, grid);
|
||||
}
|
||||
gamelistbox_->set_row_shown(lobby_info_.games_visibility());
|
||||
if (select_row >= 0 && select_row != gamelistbox_->get_selected_row()) {
|
||||
gamelistbox_->select_row(select_row);
|
||||
}
|
||||
|
@ -594,13 +592,14 @@ void tlobby_main::update_gamelist()
|
|||
gamelist_dirty_ = false;
|
||||
last_gamelist_update_ = SDL_GetTicks();
|
||||
lobby_info_.sync_games_display_status();
|
||||
lobby_info_.apply_game_filter();
|
||||
gamelistbox_->set_row_shown(lobby_info_.games_visibility());
|
||||
}
|
||||
|
||||
void tlobby_main::update_gamelist_diff()
|
||||
{
|
||||
SCOPE_LB;
|
||||
lobby_info_.make_games_vector();
|
||||
lobby_info_.apply_game_filter();
|
||||
update_gamelist_header();
|
||||
int select_row = -1;
|
||||
unsigned list_i = 0;
|
||||
|
@ -679,6 +678,8 @@ void tlobby_main::update_gamelist_diff()
|
|||
gamelist_dirty_ = false;
|
||||
last_gamelist_update_ = SDL_GetTicks();
|
||||
lobby_info_.sync_games_display_status();
|
||||
lobby_info_.apply_game_filter();
|
||||
gamelistbox_->set_row_shown(lobby_info_.games_visibility());
|
||||
}
|
||||
|
||||
void tlobby_main::update_gamelist_header()
|
||||
|
@ -799,7 +800,10 @@ void tlobby_main::adjust_game_row_contents(const game_info& game, int idx, tgrid
|
|||
|
||||
void tlobby_main::update_gamelist_filter()
|
||||
{
|
||||
DBG_LB << "tlobby_main::update_gamelist_filter\n";
|
||||
lobby_info_.apply_game_filter();
|
||||
DBG_LB << "Games in lobby_info: " << lobby_info_.games().size()
|
||||
<< ", games in listbox: " << gamelistbox_->get_item_count() << "\n";
|
||||
assert(lobby_info_.games().size() == gamelistbox_->get_item_count());
|
||||
gamelistbox_->set_row_shown(lobby_info_.games_visibility());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue