Skip to content

Commit

Permalink
Fixed line management window memory leaks.
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@8247 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
DrSuperGood committed Jun 11, 2017
1 parent 9a0bc8d commit 0be6433
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions gui/schedule_list.cc
Expand Up @@ -45,7 +45,6 @@
#include "../boden/wege/strasse.h"


#include "halt_list_stats.h"
#include "karte.h"


Expand Down Expand Up @@ -120,7 +119,9 @@ schedule_list_gui_t::schedule_list_gui_t(player_t *player_) :
scrolly_convois(&cont),
scrolly_haltestellen(&cont_haltestellen),
scl(gui_scrolled_list_t::listskin),
lbl_filter("Line Filter")
lbl_filter("Line Filter"),
convoy_infos(),
stop_infos()
{
capacity = load = 0;
selection = -1;
Expand Down Expand Up @@ -628,11 +629,16 @@ void schedule_list_gui_t::update_lineinfo(linehandle_t new_line)
icnv = new_line->count_convoys();
// display convoys of line
cont.remove_all();
while( !convoy_infos.empty() ) {
delete convoy_infos.pop_back();
}
convoy_infos.resize(icnv);
scr_coord_val ypos = 0;
for( uint32 i=0; i<icnv; i++ ) {
gui_convoiinfo_t* const cinfo = new gui_convoiinfo_t(new_line->get_convoy(i));
cinfo->set_pos(scr_coord(0, ypos));
cinfo->set_size(scr_size(400, 40));
convoy_infos.append(cinfo);
cont.add_component(cinfo);
ypos += 40;
}
Expand All @@ -653,13 +659,18 @@ void schedule_list_gui_t::update_lineinfo(linehandle_t new_line)

// fill haltestellen container with info of stops of the line
cont_haltestellen.remove_all();
while( !stop_infos.empty() ) {
delete stop_infos.pop_back();
}
stop_infos.resize(new_line->get_schedule()->entries.get_count());
ypos = 0;
FOR(minivec_tpl<schedule_entry_t>, const& i, new_line->get_schedule()->entries) {
halthandle_t const halt = haltestelle_t::get_halt(i.pos, player);
if( halt.is_bound() ) {
halt_list_stats_t* cinfo = new halt_list_stats_t(halt);
cinfo->set_pos(scr_coord(0, ypos));
cinfo->set_size(scr_size(500, 28));
stop_infos.append(cinfo);
cont_haltestellen.add_component(cinfo);
ypos += 28;
}
Expand Down
7 changes: 7 additions & 0 deletions gui/schedule_list.h
Expand Up @@ -19,6 +19,7 @@
#include "components/gui_scrollpane.h"
#include "components/gui_tab_panel.h"
#include "components/gui_convoiinfo.h"
#include "halt_list_stats.h"
#include "../simline.h"

class player_t;
Expand All @@ -42,6 +43,12 @@ class schedule_list_gui_t : public gui_frame_t, public action_listener_t
button_t filterButtons[MAX_LINE_COST];
gui_tab_panel_t tabs;

// vector of convoy info objects that are being displayed
vector_tpl<gui_convoiinfo_t *> convoy_infos;

// vector of stop info objects that are being displayed
vector_tpl<halt_list_stats_t *> stop_infos;

sint32 selection, capacity, load, loadfactor;

uint32 old_line_count;
Expand Down
1 change: 1 addition & 0 deletions simutrans/history.txt
Expand Up @@ -2,6 +2,7 @@
FIX: problems with scrolled lists
ADD: (Ichou) force replacement of wayobj by holding ctrl key while building
ADD: (THLeader) long convoi patch
FIX: Removed line management window memory leaks

Release of 120.2.2: (r8163 on 31-3-2017):
ADD: Name filter in depot window
Expand Down

0 comments on commit 0be6433

Please sign in to comment.