From 3373734bc0a2cc73e1de1be944537b501d60ed4f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 30 Sep 2022 18:02:13 +0300 Subject: [PATCH 34/34] Qt: Fix targetless revolution See osdn #45721 Signed-off-by: Marko Lindqvist --- client/gui-qt/dialogs.cpp | 13 +++++++++---- client/gui-qt/dialogs.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index a76473cf7d..428b36d5d6 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -1299,7 +1299,8 @@ void races_toggles_set_sensitive(void) void popup_revolution_dialog(struct government *gov) { hud_message_box *ask; - const Government_type_id government_id = government_number(gov); + const Government_type_id government_id + = (gov != nullptr ? government_number(gov) : G_LAST); if (0 > client.conn.playing->revolution_finishes) { ask = new hud_message_box(gui()->central_wdg); @@ -1309,10 +1310,14 @@ void popup_revolution_dialog(struct government *gov) _("Revolution!")); ask->setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ask, &hud_message_box::accepted, [=]() { - struct government *government = government_by_number(government_id); + if (government_id == G_LAST) { + revolution_response(nullptr); + } else { + struct government *government = government_by_number(government_id); - if (government) { - revolution_response(government); + if (government) { + revolution_response(government); + } } }); ask->show(); diff --git a/client/gui-qt/dialogs.h b/client/gui-qt/dialogs.h index a14b861bbb..1614697ec0 100644 --- a/client/gui-qt/dialogs.h +++ b/client/gui-qt/dialogs.h @@ -292,7 +292,7 @@ private slots: void next_unit(); }; -void popup_revolution_dialog(struct government *gov = NULL); +void popup_revolution_dialog(struct government *gov = nullptr); void revolution_response(struct government *gov); void popup_upgrade_dialog(struct unit_list *punits); void popup_disband_dialog(struct unit_list *punits); -- 2.35.1