From 3ef311007280a92fc7b13de870935844fe34b6d4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 20 Aug 2022 12:32:26 +0300 Subject: [PATCH 48/48] Qt: Fix city_production_model::populate() renegade leak See osdn #45308 Signed-off-by: Marko Lindqvist --- client/gui-qt/citydlg.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 7f1481b597..28bd0ae1cc 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -4266,7 +4266,9 @@ city_production_model::~city_production_model() ****************************************************************************/ QVariant city_production_model::data(const QModelIndex &index, int role) const { - if (!index.isValid()) return QVariant(); + if (!index.isValid()) { + return QVariant(); + } if (index.row() >= 0 && index.row() < rowCount() && index.column() >= 0 && index.column() < columnCount() @@ -4327,6 +4329,8 @@ void city_production_model::populate() if (show_units) { pi = new production_item(renegade, this); city_target_list << pi; + } else { + delete renegade; } } else { str = improvement_name_translation(renegade->value.building); @@ -4339,13 +4343,14 @@ void city_production_model::populate() && show_buildings)) { pi = new production_item(renegade, this); city_target_list << pi; + } else { + delete renegade; } } } } - renegade = NULL; - pi = new production_item(renegade, this); + pi = new production_item(nullptr, this); city_target_list << pi; sh.setX(2 * sh.y() + sh.x()); sh.setX(qMin(sh.x(), 250)); -- 2.35.1