Author: mir3x Date: Thu Oct 27 21:55:06 2016 New Revision: 34269 URL: http://svn.gna.org/viewcvs/freeciv?rev=34269&view=rev Log: Qt client - fix some memory leaks
See bug #25232 Modified: branches/S2_6/client/gui-qt/citydlg.cpp branches/S2_6/client/gui-qt/citydlg.h branches/S2_6/client/gui-qt/cityrep.cpp branches/S2_6/client/gui-qt/helpdlg.cpp branches/S2_6/client/gui-qt/hudwidget.cpp branches/S2_6/client/gui-qt/hudwidget.h branches/S2_6/client/gui-qt/menu.cpp branches/S2_6/client/gui-qt/repodlgs.cpp branches/S2_6/client/gui-qt/sidebar.cpp Modified: branches/S2_6/client/gui-qt/citydlg.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/citydlg.cpp (original) +++ branches/S2_6/client/gui-qt/citydlg.cpp Thu Oct 27 21:55:06 2016 @@ -73,6 +73,15 @@ startTimer(50); create_region(); sfont = new QFont; + m_animate_step = 0; +} + +/**************************************************************************** + Custom progressbar destructor +****************************************************************************/ +progress_bar::~progress_bar() +{ + delete sfont; } /**************************************************************************** @@ -1845,6 +1854,7 @@ city_dialog::~city_dialog() { if (citizen_pixmap) { + citizen_pixmap->detach(); delete citizen_pixmap; } @@ -2129,7 +2139,6 @@ } update_sliders(); - update_results_text(); } /**************************************************************************** @@ -2200,29 +2209,6 @@ } } -/**************************************************************************** - Updates text result in cma tab -****************************************************************************/ -void city_dialog::update_results_text() -{ - - QString str; - struct cm_parameter param; - struct cm_result *result = cm_result_new(pcity); - - cmafec_get_fe_parameter(pcity, ¶m); - cm_result_from_main_map(result, pcity); - str = cmafec_get_result_descr(pcity, result, ¶m); - cma_info_text->setText(str); - - if (!cma_is_city_under_agent(pcity, NULL)) { - cma_info_text->setDisabled(true); - } else { - cma_info_text->setDisabled(false); - } - - cm_result_destroy(result); -} /**************************************************************************** Received signal about changed qcheckbox - disband at size 1 @@ -2411,6 +2397,7 @@ height = h; if (citizen_pixmap) { + citizen_pixmap->detach(); delete citizen_pixmap; } Modified: branches/S2_6/client/gui-qt/citydlg.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.h?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/citydlg.h (original) +++ branches/S2_6/client/gui-qt/citydlg.h Thu Oct 27 21:55:06 2016 @@ -78,6 +78,7 @@ public: progress_bar(QWidget *parent); + ~progress_bar(); void mousePressEvent(QMouseEvent *event) { emit clicked(); } @@ -473,7 +474,6 @@ void worklist_del(); void display_worklist_menu(const QPoint &p); void disband_state_changed(int state); - void update_results_text(); void cma_slider(int val); void cma_celebrate_changed(int val); void cma_remove(); Modified: branches/S2_6/client/gui-qt/cityrep.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/cityrep.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/cityrep.cpp (original) +++ branches/S2_6/client/gui-qt/cityrep.cpp Thu Oct 27 21:55:06 2016 @@ -168,6 +168,7 @@ city_model::~city_model() { qDeleteAll(city_list); + city_list.clear(); } /*************************************************************************** Modified: branches/S2_6/client/gui-qt/helpdlg.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/helpdlg.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/helpdlg.cpp (original) +++ branches/S2_6/client/gui-qt/helpdlg.cpp Thu Oct 27 21:55:06 2016 @@ -185,7 +185,7 @@ int dep; int i; QHash<int, QTreeWidgetItem *> hash; - QIcon *icon; + QIcon icon; QTreeWidgetItem *item; sprite *spite; struct advance *padvance; @@ -210,7 +210,6 @@ topics_map[item] = pitem; dep = s - pitem->topic; hash.insert(dep, item); - icon = nullptr; if (dep == 0) { tree_wdg->addTopLevelItem(item); @@ -222,14 +221,14 @@ case HELP_EXTRA: pextra = extra_type_by_translated_name(s); fill_basic_extra_sprite_array(tileset, sprs, pextra); - icon = new QIcon(*sprs->sprite->pm); + icon = QIcon(*sprs->sprite->pm); break; case HELP_GOVERNMENT: gov = government_by_translated_name(s); spite = get_government_sprite(tileset, gov); if (spite) { - icon = new QIcon(*spite->pm); + icon = QIcon(*spite->pm); } break; @@ -238,7 +237,7 @@ imp = improvement_by_translated_name(s); spite = get_building_sprite(tileset, imp); if (spite) { - icon = new QIcon(*spite->pm); + icon = QIcon(*spite->pm); } break; @@ -247,7 +246,7 @@ if (padvance && !is_future_tech(i = advance_number(padvance))) { spite = get_tech_sprite(tileset, i); if (spite) { - icon = new QIcon(*spite->pm); + icon = QIcon(*spite->pm); } } break; @@ -256,7 +255,7 @@ pterrain = terrain_by_translated_name(s); pcan = terrain_canvas(pterrain); if (pcan) { - icon = new QIcon(pcan->map_pixmap); + icon = QIcon(pcan->map_pixmap); delete pcan; } break; @@ -268,7 +267,7 @@ true); } if (spite) { - icon = new QIcon(*spite->pm); + icon = QIcon(*spite->pm); } break; @@ -276,8 +275,8 @@ break; } - if (icon != nullptr) { - item->setIcon(0, *icon); + if (icon.isNull() == false) { + item->setIcon(0, icon); } hash.value(last)->addChild(item); Modified: branches/S2_6/client/gui-qt/hudwidget.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/hudwidget.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/hudwidget.cpp (original) +++ branches/S2_6/client/gui-qt/hudwidget.cpp Thu Oct 27 21:55:06 2016 @@ -66,10 +66,19 @@ fm_text = new QFontMetrics(f_text); fm_title = new QFontMetrics(f_title); top = 0; + m_animate_step = 0; hide(); mult = 1; } +/**************************************************************************** + Custom message box destructor +****************************************************************************/ +hud_message_box::~hud_message_box() +{ + delete fm_text; + delete fm_title; +} /**************************************************************************** Key press event for hud message box ****************************************************************************/ @@ -218,10 +227,19 @@ fm_text = new QFontMetrics(f_text); fm_title = new QFontMetrics(f_title); top = 0; + m_animate_step = 0; hide(); mult = 1; } +/**************************************************************************** + Custom input box destructor +****************************************************************************/ +hud_input_box::~hud_input_box() +{ + delete fm_text; + delete fm_title; +} /**************************************************************************** Sets text, title and default text and shows input box ****************************************************************************/ @@ -380,7 +398,6 @@ ****************************************************************************/ hud_units::~hud_units() { - } @@ -549,6 +566,7 @@ connect(this, SIGNAL(left_clicked()), SLOT(on_clicked())); setFocusPolicy(Qt::ClickFocus); focus = false; + action_pixmap = nullptr; } /**************************************************************************** @@ -589,7 +607,9 @@ ****************************************************************************/ hud_action::~hud_action() { - + if (action_pixmap) { + delete action_pixmap; + } } /**************************************************************************** Modified: branches/S2_6/client/gui-qt/hudwidget.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/hudwidget.h?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/hudwidget.h (original) +++ branches/S2_6/client/gui-qt/hudwidget.h Thu Oct 27 21:55:06 2016 @@ -41,6 +41,7 @@ public: hud_message_box(QWidget *parent); + ~hud_message_box(); void set_text_title(QString s1, QString s2); protected: @@ -70,6 +71,7 @@ public: hud_input_box(QWidget *parent); + ~hud_input_box(); void set_text_title_definput(QString s1, QString s2, QString def_input); QLineEdit input_edit; @@ -155,8 +157,6 @@ class hud_units: public QFrame { Q_OBJECT - QPixmap *unit_pix; - QPixmap *tile_pix; click_label unit_label; click_label tile_label; QLabel text_label; Modified: branches/S2_6/client/gui-qt/menu.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/menu.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/menu.cpp (original) +++ branches/S2_6/client/gui-qt/menu.cpp Thu Oct 27 21:55:06 2016 @@ -640,6 +640,8 @@ ****************************************************************************/ gov_menu::~gov_menu() { + delete gov_mapper; + qDeleteAll(actions); instances.remove(this); } Modified: branches/S2_6/client/gui-qt/repodlgs.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/repodlgs.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/repodlgs.cpp (original) +++ branches/S2_6/client/gui-qt/repodlgs.cpp Thu Oct 27 21:55:06 2016 @@ -102,6 +102,8 @@ { qtg_canvas_free(pcanvas); destroy_reqtree(req); + qDeleteAll(tt_help); + tt_help.clear(); } /**************************************************************************** Modified: branches/S2_6/client/gui-qt/sidebar.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/sidebar.cpp?rev=34269&r1=34268&r2=34269&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/sidebar.cpp (original) +++ branches/S2_6/client/gui-qt/sidebar.cpp Thu Oct 27 21:55:06 2016 @@ -68,7 +68,6 @@ wheel_down = nullptr; wheel_up = nullptr; page = pg; - def_pixmap = nullptr; setContextMenuPolicy(Qt::CustomContextMenu); timer = new QTimer; timer->setSingleShot(false); @@ -88,6 +87,11 @@ if (def_pixmap) { delete def_pixmap; } + + if (final_pixmap) { + delete final_pixmap; + } + delete timer; } /*************************************************************************** @@ -340,11 +344,16 @@ pos = 0; int d, modulo; sprite = get_tax_sprite(tileset, O_GOLD); + if (sprite == nullptr) { + return; + } w = width() / 10; modulo = width() % 10; h = sprite->pm->height(); reduce_mod(modulo, pos); - + if (client.conn.playing == nullptr) { + return; + } for (d = 0; d < client.conn.playing->economic.tax / 10; ++d) { p.drawPixmap(pos, 5, sprite->pm->scaled(w, h), 0, 0, w, h); pos = pos + w; @@ -444,7 +453,9 @@ ***************************************************************************/ fc_sidebar::~fc_sidebar() { - + if (sidebar_img) { + delete sidebar_img; + } } /*************************************************************************** _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits