From fdf6155f496ed835cf1853b13f13eaa31a4c436c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 22 Sep 2021 06:01:31 +0300 Subject: [PATCH 15/15] Qt plr_report::update_report(): Update number of rows as the first action Make sure the number of rows is correct, for example after civil war, before we may trigger automatic sorting of the model. Reported by chippo See osdn #42545 Signed-off-by: Marko Lindqvist --- client/gui-qt/plrdlg.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/client/gui-qt/plrdlg.cpp b/client/gui-qt/plrdlg.cpp index fdab152e87..e13df69f14 100644 --- a/client/gui-qt/plrdlg.cpp +++ b/client/gui-qt/plrdlg.cpp @@ -813,16 +813,11 @@ void plr_report::update_report(bool update_selection) { QModelIndex qmi; int player_count = 0; - - /* Force updating selected player information */ - if (update_selection) { - qmi = plr_wdg->currentIndex(); - if (qmi.isValid()) { - plr_wdg->clearSelection(); - plr_wdg->setCurrentIndex(qmi); - } - } + /* First make sure number of rows is correct - there can be new + * nations because of civil war. We don't want our actions to + * trigger automatic sorting of the model while number of rows + * is not correct. */ players_iterate(pplayer) { if ((is_barbarian(pplayer))){ continue; @@ -834,6 +829,15 @@ void plr_report::update_report(bool update_selection) plr_wdg->get_model()->populate(); } + /* Force updating selected player information */ + if (update_selection) { + qmi = plr_wdg->currentIndex(); + if (qmi.isValid()) { + plr_wdg->clearSelection(); + plr_wdg->setCurrentIndex(qmi); + } + } + plr_wdg->header()->resizeSections(QHeaderView::ResizeToContents); meet_but->setDisabled(true); cancel_but->setDisabled(true); -- 2.33.0