From efffd73980a175afb737265ab57f8d4eb177fa02 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 23 Jun 2023 19:48:29 +0300 Subject: [PATCH 18/18] Qt: Construct impr sell box only if needed See osdn #48275 Signed-off-by: Marko Lindqvist --- client/gui-qt/citydlg.cpp | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index b82f65aa76..10a3367372 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -598,40 +598,38 @@ void impr_item::wheelEvent(QWheelEvent *event) ****************************************************************************/ void impr_item::mouseDoubleClickEvent(QMouseEvent *event) { - hud_message_box ask(city_dlg); - QString s; - char buf[256]; - int price; - int ret; - if (!can_client_issue_orders()) { return; } if (event->button() == Qt::LeftButton) { - if (test_player_sell_building_now(client.conn.playing, pcity, - impr) != TR_SUCCESS) { - return; - } - - price = impr_sell_gold(impr); - fc_snprintf(buf, ARRAY_SIZE(buf), - PL_("Sell %s for %d gold?", - "Sell %s for %d gold?", price), - city_improvement_name_translation(pcity, impr), price); - - s = QString(buf); - ask.set_text_title(s, (_("Sell improvement?"))); - ask.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok); - ret = ask.exec(); - - switch (ret) { - case QMessageBox::Cancel: - return; - - case QMessageBox::Ok: - city_sell_improvement(pcity, improvement_number(impr)); - break; + if (test_player_sell_building_now(client_player(), pcity, + impr) == TR_SUCCESS) { + QString s; + char buf[256]; + int price; + int ret; + hud_message_box ask(city_dlg); + + price = impr_sell_gold(impr); + fc_snprintf(buf, ARRAY_SIZE(buf), + PL_("Sell %s for %d gold?", + "Sell %s for %d gold?", price), + city_improvement_name_translation(pcity, impr), price); + + s = QString(buf); + ask.set_text_title(s, (_("Sell improvement?"))); + ask.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok); + ret = ask.exec(); + + switch (ret) { + case QMessageBox::Cancel: + return; + + case QMessageBox::Ok: + city_sell_improvement(pcity, improvement_number(impr)); + break; + } } } } -- 2.40.1