[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1741778-statistics_window_leaks into lp:widelands

2018-01-09 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/bug-1741778-statistics_window_leaks into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1741778 in widelands: "Plot area of Statistics has memory leak"
  https://bugs.launchpad.net/widelands/+bug/1741778

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1741778-statistics_window_leaks/+merge/335897

The changes in the branch fix the memory leaks reported in the bug 1741778. 

So, the problem is that WuiPlotArea allocates memory but doesn't release it. 
Memory leak happens when player leaves from a game. The leak is not fatal, but 
it should be fixed. The fix isn't the most stylish one but it does the work.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1741778-statistics_window_leaks into 
lp:widelands.
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc	2017-11-12 13:34:46 +
+++ src/wui/plot_area.cc	2018-01-09 18:46:15 +
@@ -473,7 +473,7 @@
 	//  plot the pixels
 	for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
 		if (plotdata_[plot].showplot) {
-			draw_plot_line(dst, (plotmode_ == Plotmode::kRelative) ? plotdata_[plot].relative_data :
+			draw_plot_line(dst, (plotmode_ == Plotmode::kRelative) ? plotdata_[plot].relative_data.get() :
 			 plotdata_[plot].absolute_data,
 			   highest_scale, sub_, plotdata_[plot].plotcolor, yoffset);
 		}
@@ -537,8 +537,7 @@
 		plotdata_.resize(id + 1);
 
 	plotdata_[id].absolute_data = data;
-	plotdata_[id].relative_data =
-	   new std::vector();  // Will be filled in the update() function.
+	plotdata_[id].relative_data.reset(new std::vector());  // Will be filled in the update() function.
 	plotdata_[id].showplot = false;
 	plotdata_[id].plotcolor = color;
 

=== modified file 'src/wui/plot_area.h'
--- src/wui/plot_area.h	2017-05-04 04:37:16 +
+++ src/wui/plot_area.h	2018-01-09 18:46:15 +
@@ -21,6 +21,7 @@
 #define WL_WUI_PLOT_AREA_H
 
 #include 
+#include 
 
 #include 
 
@@ -116,7 +117,7 @@
 
 	struct PlotData {
 		const std::vector* absolute_data;  // The absolute dataset
-		std::vector* relative_data;// The relative dataset
+		std::unique_ptr > relative_data;// The relative dataset
 		bool showplot;
 		RGBColor plotcolor;
 	};

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands

2017-12-21 Thread Jukka Pakarinen
The proposal to merge 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands 
has been updated.

Commit Message changed to:

Fix heap use after free bug, and avoid immovables to end up wrong positions 
when pressing undo/redo in editor

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fix-bug-1735980-related-problems/+merge/335403
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands

2017-12-20 Thread Jukka Pakarinen
The proposal to merge 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands 
has been updated.

Commit Message changed to:

Fix bug 1735980 related problems

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fix-bug-1735980-related-problems/+merge/335403
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands

2017-12-19 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1735980 in widelands: "use-after-free in editor"
  https://bugs.launchpad.net/widelands/+bug/1735980

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fix-bug-1735980-related-problems/+merge/335403

The branch includes bug fixes described on bug 1735980.

The original problem of the bug 1735980 was heap-use-after-free found when the 
game was run with asan library and undo was applied to water with fish. The 
other problem concerned an applied immovable (ruin) moved to an unexpected 
posion on the map when the origin if the map was set.

The commit messages explain shortly why it fixes the bug.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/fix-bug-1735980-related-problems into lp:widelands.
=== modified file 'src/editor/tools/set_origin_tool.cc'
--- src/editor/tools/set_origin_tool.cc	2017-08-17 15:34:45 +
+++ src/editor/tools/set_origin_tool.cc	2017-12-19 18:24:38 +
@@ -41,7 +41,14 @@
   EditorActionArgs* /* args */,
   Widelands::Map* map) {
 	Widelands::Coords nc(
-	   map->get_width() - 1 - center.node.x, map->get_height() - 1 - center.node.y);
+	   map->get_width() - center.node.x, map->get_height() - center.node.y);
+
+	// Because of the triangle design of map, y is changed by an odd number.
+	// The x must be syncronized with the y when coordinate pair is applied
+	// and also when undoing an action like here.
+	if ((nc.y % 2) != 0)
+		nc.x = nc.x - 1;
+	map->normalize_coords(nc);
 	map->set_origin(nc);
 	eia.map_changed(EditorInteractive::MapWas::kGloballyMutated);
 	eia.map_view()->scroll_to_field(Widelands::Coords(0, 0), MapView::Transition::Jump);

=== modified file 'src/logic/map.cc'
--- src/logic/map.cc	2017-12-18 10:42:40 +
+++ src/logic/map.cc	2017-12-19 18:24:38 +
@@ -359,7 +359,8 @@
 		}
 	}
 	// Now that we restructured the fields, we just overwrite the old order
-	fields_.reset(new_field_order.release());
+	for (decltype(width_) ind = 0; ind < width_*height_; ind++)
+		fields_[ind] = new_field_order[ind];
 
 	//  Inform immovables and bobs about their new coordinates.
 	for (FCoords c(Coords(0, 0), fields_.get()); c.y < height_; ++c.y)

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into lp:widelands

2017-12-04 Thread Jukka Pakarinen
The proposal to merge 
lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into 
lp:widelands has been updated.

Description changed to:

The change in the branch fixes the bug 1699778. update() function sets the 
ww_valid flag off which means that multilineeditbox must be refreshed. Without 
the function call refresh will happen during a next call of some other key 
which sets the flag off.

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter/+merge/334683
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into 
lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into lp:widelands

2017-12-04 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1699778 in widelands: "Multilineeditbox: Advance cursor to the next line 
when enter is hit at the end of the string being edited"
  https://bugs.launchpad.net/widelands/+bug/1699778

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter/+merge/334683

The change in the branch fixes the bug 1699778.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1699778-multilineeditbox-handle-key-enter into 
lp:widelands.
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc	2017-09-20 21:27:25 +
+++ src/ui_basic/multilineeditbox.cc	2017-12-04 16:56:11 +
@@ -375,6 +375,7 @@
 		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			d_->insert(d_->cursor_pos, "\n");
+			d_->update();
 			changed();
 			break;
 

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/multilineeditbox-uninitialized_value into lp:widelands

2017-12-03 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/multilineeditbox-uninitialized_value into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/multilineeditbox-uninitialized_value/+merge/334642

During wondering of the bug 1699778, I found (with consulting the Valgrind) 
multiple comparisons depend on uninitialised value(s). The cases are reported 
in the bug. The change in the branch fix those comparison problems.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/multilineeditbox-uninitialized_value into 
lp:widelands.
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc	2017-09-20 21:27:25 +
+++ src/ui_basic/multilineeditbox.cc	2017-12-03 17:47:01 +
@@ -105,6 +105,7 @@
: scrollbar(&o, o.get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, o.get_h(), button_background),
  background(init_background),
  cursor_pos(0),
+ lineheight(1),
  maxbytes(std::min(g_gr->max_texture_size() / UI_FONT_SIZE_SMALL, 0x)),
  ww_valid(false),
  owner(o) {

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/enemysites_check_delay_used_before_initialized into lp:widelands

2017-11-26 Thread Jukka Pakarinen
Ok, I change the value!
-- 
https://code.launchpad.net/~widelands-dev/widelands/enemysites_check_delay_used_before_initialized/+merge/334287
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/enemysites_check_delay_used_before_initialized into 
lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/enemysites_check_delay_used_before_initialized into lp:widelands

2017-11-26 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/enemysites_check_delay_used_before_initialized into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1734544 in widelands: "Member variable 
DefaultAI::enemysites_check_delay_ used before initialization"
  https://bugs.launchpad.net/widelands/+bug/1734544

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/enemysites_check_delay_used_before_initialized/+merge/334287

DefaultAI::enemysites_check_delay_ variable is not initialized before it is 
used. 
The fix in the branch fixes the bug 1734544.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/enemysites_check_delay_used_before_initialized into 
lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2017-11-20 07:54:19 +
+++ src/ai/defaultai.cc	2017-11-26 17:19:38 +
@@ -106,6 +106,7 @@
  ts_in_const_count_(0),
  ts_without_trainers_(0),
  inhibit_road_building_(0),
+ enemysites_check_delay_(0),
  resource_necessity_water_needed_(false),
  highest_nonmil_prio_(0),
  seafaring_economy(false),

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/scenario_types_used_before_initialized into lp:widelands

2017-11-26 Thread Jukka Pakarinen
Of course I can! In that way it is even more readable. Thanks!
-- 
https://code.launchpad.net/~widelands-dev/widelands/scenario_types_used_before_initialized/+merge/334285
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/scenario_types_used_before_initialized into 
lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/scenario_types_used_before_initialized into lp:widelands

2017-11-26 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~widelands-dev/widelands/scenario_types_used_before_initialized into 
lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/scenario_types_used_before_initialized/+merge/334285

When "New Game" button is pressed on the "Single Player" view, Valgrind detects 
that there is some value(s) used before initialization.

==6183== Conditional jump or move depends on uninitialised value(s)
==6183==at 0xD65F0A: FullscreenMenuMapSelect::fill_table() 
(mapselect.cc:257)
==6183==by 0xD6674F: FullscreenMenuMapSelect::tagbox_changed(int, bool) 
(mapselect.cc:340)
==6183==by 0xD6B0AF: boost::_mfi::mf2::operator()(FullscreenMenuMapSelect*, int, bool) const 
(mem_fn_template.hpp:280)

The commit in the branch moves the initialization of scenario_types_ variable 
before the first call of fill_table method. Valgrind doesn't give the message 
wtih the fix.

-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/scenario_types_used_before_initialized into 
lp:widelands.
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc	2017-11-05 19:59:33 +
+++ src/ui_fsmenu/mapselect.cc	2017-11-26 14:52:10 +
@@ -83,6 +83,8 @@
 
 	UI::Box* hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
 
+	scenario_types_ = settings_->settings().multiplayer ? Map::MP_SCENARIO : Map::SP_SCENARIO;
+
 	// Must be initialized before tag checkboxes
 	cb_dont_localize_mapnames_ =
 	   new UI::Checkbox(hbox, Vector2i::zero(), _("Show original map names"));
@@ -116,8 +118,6 @@
 	add_tag_checkbox(hbox, "4teams", localize_tag("4teams"));
 	checkboxes_.add(hbox, UI::Box::Resizing::kFullSize);
 
-	scenario_types_ = settings_->settings().multiplayer ? Map::MP_SCENARIO : Map::SP_SCENARIO;
-
 	table_.focus();
 	fill_table();
 

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~flegu/widelands/fix_some_memory_leaks into lp:widelands

2017-11-17 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging lp:~flegu/widelands/fix_some_memory_leaks 
into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~flegu/widelands/fix_some_memory_leaks/+merge/333930

There happens memory leaks detected with Valgrind in multiple menu views. The 
changes in the branch fixes most of the cases. The leaks were found when the 
game was built from trunk (revno 8490) on Debian 9.1. I think these leaks are 
definitely happening on every operating system.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~flegu/widelands/fix_some_memory_leaks into lp:widelands.
=== modified file 'src/ui_fsmenu/campaign_select.cc'
--- src/ui_fsmenu/campaign_select.cc	2017-03-05 17:55:29 +
+++ src/ui_fsmenu/campaign_select.cc	2017-11-18 07:26:04 +
@@ -493,4 +493,5 @@
 		table_.select(0);
 	}
 	set_has_selection();
+	delete prof;
 }

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2017-11-06 20:19:56 +
+++ src/ui_fsmenu/loadgame.cc	2017-11-18 07:26:04 +
@@ -114,7 +114,7 @@
 		return;
 	}
 
-	const SavegameData* gamedata = load_or_save_.entry_selected();
+	const std::shared_ptr gamedata = load_or_save_.entry_selected();
 	if (gamedata && gamedata->errormessage.empty()) {
 		filename_ = gamedata->filename;
 		end_modal(FullscreenMenuBase::MenuTarget::kOk);

=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc	2017-11-12 08:04:06 +
+++ src/ui_fsmenu/options.cc	2017-11-18 07:26:04 +
@@ -453,6 +453,7 @@
 LanguageEntry* entry = new LanguageEntry(localename, name);
 entries.insert(std::make_pair(sortname, *entry));
 language_entries_.insert(std::make_pair(localename, *entry));
+delete entry;
 
 if (localename == current_locale) {
 	selected_locale = current_locale;

=== modified file 'src/wui/load_or_save_game.cc'
--- src/wui/load_or_save_game.cc	2017-11-06 20:19:56 +
+++ src/wui/load_or_save_game.cc	2017-11-18 07:26:04 +
@@ -168,8 +168,8 @@
 	return r1.savetimestamp < r2.savetimestamp;
 }
 
-const SavegameData* LoadOrSaveGame::entry_selected() {
-	SavegameData* result = new SavegameData();
+const std::shared_ptr LoadOrSaveGame::entry_selected() {
+	std::shared_ptr result = std::make_shared(SavegameData());
 	size_t selections = table_.selections().size();
 	if (selections == 1) {
 		delete_->set_tooltip(
@@ -178,7 +178,7 @@
 		  _("Delete this replay") :
 		  /** TRANSLATORS: Tooltip for the delete button. The user has selected 1 file */
 		  _("Delete this game"));
-		result = &games_data_[table_.get_selected()];
+		result = std::make_shared(games_data_[table_.get_selected()]);
 	} else if (selections > 1) {
 		delete_->set_tooltip(
 		   filetype_ == FileType::kReplay ?

=== modified file 'src/wui/load_or_save_game.h'
--- src/wui/load_or_save_game.h	2017-08-12 08:03:19 +
+++ src/wui/load_or_save_game.h	2017-11-18 07:26:04 +
@@ -43,7 +43,7 @@
 	   bool localize_autosave);
 
 	/// Update gamedetails and tooltips and return information about the current selection
-	const SavegameData* entry_selected();
+	const std::shared_ptr entry_selected();
 
 	/// Whether the table has a selection
 	bool has_selection() const;

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


Re: [Widelands-dev] [Merge] lp:~flegu/widelands/r8481-renderedtext-memory-leaks into lp:widelands

2017-11-11 Thread Jukka Pakarinen
> Thanks for the fix!
> 
> Looks good to me - can you please replace UI::RenderedText::Shared with
> std::shared_ptr and get rid of the new using statement? I
> think that would make the code easier to read.

Sure, I can do that.
-- 
https://code.launchpad.net/~flegu/widelands/r8481-renderedtext-memory-leaks/+merge/333578
Your team Widelands Developers is requested to review the proposed merge of 
lp:~flegu/widelands/r8481-renderedtext-memory-leaks into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~flegu/widelands/r8481-renderedtext-memory-leaks into lp:widelands

2017-11-11 Thread Jukka Pakarinen
Jukka Pakarinen has proposed merging 
lp:~flegu/widelands/r8481-renderedtext-memory-leaks into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~flegu/widelands/r8481-renderedtext-memory-leaks/+merge/333578

Valgrind analysis reveals memory leaks from RenderedText objects during startup 
of the game. The leaks are already reported in bug 1668200 #4 #6. 

The leaks are detected in Debug and Release builds on Debian 9.1. Valgrind does 
not see the leaks if a build is done with the changes in the branch.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~flegu/widelands/r8481-renderedtext-memory-leaks into lp:widelands.
=== modified file 'src/graphic/text/rendered_text.h'
--- src/graphic/text/rendered_text.h	2017-06-24 08:47:46 +
+++ src/graphic/text/rendered_text.h	2017-11-11 14:31:33 +
@@ -115,7 +115,9 @@
 };
 
 struct RenderedText {
-	/// RenderedRects that can be drawn on screen
+using Shared = std::shared_ptr;
+
+/// RenderedRects that can be drawn on screen
 	std::vector> rects;
 
 	/// The width occupied  by all rects in pixels.

=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc	2017-08-18 14:27:26 +
+++ src/graphic/text/rt_render.cc	2017-11-11 14:31:33 +
@@ -230,7 +230,7 @@
 	virtual uint16_t width() const = 0;
 	virtual uint16_t height() const = 0;
 	virtual uint16_t hotspot_y() const = 0;
-	virtual UI::RenderedText* render(TextureCache* texture_cache) = 0;
+	virtual UI::RenderedText::Shared render(TextureCache* texture_cache) = 0;
 
 	// TODO(GunChleoc): Remove this function once conversion is finished and well tested.
 	virtual std::string debug_info() const = 0;
@@ -527,7 +527,7 @@
 		return rv;
 	}
 
-	UI::RenderedText* render(TextureCache* texture_cache) override;
+UI::RenderedText::Shared render(TextureCache* texture_cache) override;
 
 protected:
 	uint16_t w_, h_;
@@ -550,11 +550,11 @@
 	return font_.ascent(nodestyle_.font_style);
 }
 
-UI::RenderedText* TextNode::render(TextureCache* texture_cache) {
+UI::RenderedText::Shared TextNode::render(TextureCache* texture_cache) {
 	auto rendered_image =
 	   font_.render(txt_, nodestyle_.font_color, nodestyle_.font_style, texture_cache);
 	assert(rendered_image.get() != nullptr);
-	UI::RenderedText* rendered_text = new UI::RenderedText();
+	UI::RenderedText::Shared rendered_text(new UI::RenderedText());
 	rendered_text->rects.push_back(
 	   std::unique_ptr(new UI::RenderedRect(rendered_image)));
 	return rendered_text;
@@ -579,7 +579,7 @@
 		return "ft";
 	}
 
-	UI::RenderedText* render(TextureCache*) override;
+UI::RenderedText::Shared render(TextureCache*) override;
 
 	bool is_expanding() const override {
 		return is_expanding_;
@@ -591,8 +591,8 @@
 private:
 	bool is_expanding_;
 };
-UI::RenderedText* FillingTextNode::render(TextureCache* texture_cache) {
-	UI::RenderedText* rendered_text = new UI::RenderedText();
+UI::RenderedText::Shared FillingTextNode::render(TextureCache* texture_cache) {
+UI::RenderedText::Shared rendered_text(new UI::RenderedText());
 	const std::string hash =
 	   (boost::format("rt:fill:%s:%s:%i:%i:%i:%s") % txt_ % nodestyle_.font_color.hex_value() %
 	nodestyle_.font_style % width() % height() % (is_expanding_ ? "e" : "f"))
@@ -633,9 +633,9 @@
 		return "wsp";
 	}
 
-	UI::RenderedText* render(TextureCache* texture_cache) override {
+UI::RenderedText::Shared render(TextureCache* texture_cache) override {
 		if (show_spaces_) {
-			UI::RenderedText* rendered_text = new UI::RenderedText();
+		UI::RenderedText::Shared rendered_text(new UI::RenderedText());
 			const std::string hash = (boost::format("rt:wsp:%i:%i") % width() % height()).str();
 			std::shared_ptr rendered_image = texture_cache->get(hash);
 			if (rendered_image.get() == nullptr) {
@@ -681,7 +681,7 @@
 	uint16_t hotspot_y() const override {
 		return 0;
 	}
-	UI::RenderedText* render(TextureCache* /* texture_cache */) override {
+UI::RenderedText::Shared render(TextureCache* /* texture_cache */) override {
 		NEVER_HERE();
 	}
 	bool is_non_mandatory_space() const override {
@@ -712,8 +712,8 @@
 	uint16_t hotspot_y() const override {
 		return h_;
 	}
-	UI::RenderedText* render(TextureCache* texture_cache) override {
-		UI::RenderedText* rendered_text = new UI::RenderedText();
+UI::RenderedText::Shared render(TextureCache* texture_cache) override {
+	UI::RenderedText::Shared rendered_text(new UI::RenderedText());
 		const std::string hash = (boost::format("rt:sp:%s:%i:%i:%s") % filename_ % width() %
 		  height() % (is_expanding_ ? "e" : "f"))
 		.str();
@@ -802,8 +802,8 @@
 		return desired_width_;
 	}
 
-	UI::RenderedText* render(TextureCache* t

Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/savegame-menu into lp:widelands

2017-10-31 Thread Jukka Pakarinen
I have been testing the branch and today got it crash.

This is how it crashes:

Single Player
New Game
Click Crater and then OK
Start game
Main Menu
Save Game
Write some Filename and then OK
Main Menu
Exit Game 
OK
Watch Replay
Choose the saved game and then OK
Wait until the end of replay and "End of repaly" message pops up.
Click OK
Game crashes, "Segmentation fault"




Here is few lines of what gdb says about it.



REPLAY: End of replay (gametime: 10434)

Thread 1 "widelands" received signal SIGSEGV, Segmentation fault.
0x5610c735 in UI::Button::set_enabled (this=0x0, on=false) at 
/usr/src/bzr/widelands-repo/savegame-menu/src/ui_basic/button.cc:128
128 if (enabled_ == on)
#0  0x5610c735 in UI::Button::set_enabled (this=0x0, on=false) at 
/usr/src/bzr/widelands-repo/savegame-menu/src/ui_basic/button.cc:128
#1  0x5611cdec in UI::WLMessageBox::clicked_ok (this=0x7fffa520) at 
/usr/src/bzr/widelands-repo/savegame-menu/src/ui_basic/messagebox.cc:150
#2  0x5611dc6f in boost::_mfi::mf0::operator() 
(this=0x5d6f5230, t=...) at /usr/include/boost/bind/mem_fn_template.hpp:70




I tested the same with trunk and it didn't crash.

-- 
https://code.launchpad.net/~widelands-dev/widelands/savegame-menu/+merge/322924
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/savegame-menu.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp