Merge lp:~widelands-dev/widelands/bug-1653460-panel-init-width into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8313
Proposed branch: lp:~widelands-dev/widelands/bug-1653460-panel-init-width
Merge into: lp:widelands
Diff against target: 531 lines (+82/-61)
22 files modified
src/ui_basic/box.cc (+7/-6)
src/ui_basic/fileview_panel.cc (+3/-0)
src/ui_basic/listselect.cc (+1/-2)
src/ui_basic/multilineeditbox.cc (+5/-5)
src/ui_basic/multilinetextarea.cc (+1/-1)
src/ui_basic/panel.cc (+21/-4)
src/ui_basic/panel.h (+2/-8)
src/ui_basic/scrollbar.cc (+1/-1)
src/ui_basic/spinbox.cc (+18/-17)
src/ui_basic/table.cc (+5/-8)
src/ui_basic/table.h (+5/-4)
src/ui_basic/tabpanel.cc (+2/-2)
src/ui_basic/textarea.cc (+1/-1)
src/ui_basic/window.cc (+1/-1)
src/ui_fsmenu/campaign_select.cc (+1/-0)
src/ui_fsmenu/internet_lobby.cc (+1/-0)
src/ui_fsmenu/loadgame.cc (+2/-0)
src/ui_fsmenu/netsetup_lan.cc (+1/-0)
src/wui/actionconfirm.cc (+1/-1)
src/wui/game_message_menu.cc (+1/-0)
src/wui/game_summary.cc (+1/-0)
src/wui/maptable.cc (+1/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1653460-panel-init-width
Reviewer Review Type Date Requested Status
Klaus Halfmann code review Approve
kaputtnik (community) testing Approve
GunChleoc Needs Resubmitting
Review via email: mp+318358@code.launchpad.net

Commit message

Fixed assertion failure in int UI::Panel::get_inner_h():

- Fixed bug with automatic column sizing for tables where the columns were already being resized before all of them were added.
- Allow getting inner width/height for panels that have their borders set but w/h == 0. Added assertions and fallbacks to set_size and set_desired_size to make sure that width/height will never be negative.
- Explicitly initialize all variables in ui_basic.
- Only layout spinbox if it has size.

Description of the change

The assertion in the bug should now be fixed for all panels containing tables:

* Fullscreen menus:

    - campaign_select
    - internet_lobby
    - launch_mpg
    - launch_spg
    - loadgame
    - mapselect
    - netsetup_lan

* In-game:
    - game_message_menu
    - game_summary
    - productionsitewindow
    - trainingsitewindow
    - tribal_encyclopedia

* Editor:
    - help
    - main_menu_load_map
    - main_menu_save_map

I don't know why this happened only sometimes and not all the time though.

To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Going to fetch this now, but will need som testing on my multi Monitor setup.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Now Can always reproduce this :-(

Open in fullscreeen mode:

**** GRAPHICS REPORT ****
 VIDEO DRIVER cocoa
 pixel fmt 372645892
 size 1440 900
**** END GRAPHICS REPORT ****

Open options menu:
4 widelands 0x0000000100946b2e UI::Panel::set_size(int, int) + 142 (panel.cc:243)
5 widelands 0x000000010095af4b UI::SpinBox::layout() + 1131 (spinbox.cc:202)
6 widelands 0x000000010095a3ae UI::SpinBox::SpinBox(UI::Panel*, int, int, unsigned int, unsigned int, int, int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, UI::SpinBox::Units const&, Image const*, UI::SpinBox::Type, int, int) + 10814 (spinbox.cc:171)
7 widelands 0x000000010095a9c9 UI::SpinBox::SpinBox(UI::Panel*, int, int, unsigned int, unsigned int, int, int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, UI::SpinBox::Units const&, Image const*, UI::SpinBox::Type, int, int) + 249 (spinbox.cc:173)
8 widelands 0x0000000100a0ee9c FullscreenMenuOptions::FullscreenMenuOptions(OptionsCtrl::OptionsStruct) + 8076 (options.cc:152)

So I would suggest we should spin^h^h^h^h fix these Boxes, too.

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

konsole output and Backtrace:

widelands: /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/panel.cc:243: void UI::Panel::set_size(int, int): Assertion `nw >= 0' failed.

Thread 1 "widelands" received signal SIGABRT, Aborted.
0x00007ffff513b04f in raise () from /usr/lib/libc.so.6
(gdb) backtrace
#0 0x00007ffff513b04f in raise () from /usr/lib/libc.so.6
#1 0x00007ffff513c47a in abort () from /usr/lib/libc.so.6
#2 0x00007ffff5133ea7 in __assert_fail_base () from /usr/lib/libc.so.6
#3 0x00007ffff5133f52 in __assert_fail () from /usr/lib/libc.so.6
#4 0x0000000000edafe4 in UI::Panel::set_size (this=0x1c30c40, nw=-8, nh=10)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/panel.cc:243
#5 0x0000000000ee55ad in UI::SpinBox::layout (this=0x1c08e70) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/spinbox.cc:201
#6 0x0000000000ee4fb3 in UI::SpinBox::SpinBox (this=0x1c08e70, parent=0x1c077c8, x=0, y=0, w=0, unit_w=0, startval=30, minval=0, maxval=99, label_text="Maximum FPS:",
    unit=@0x7fffffffbc4c: UI::SpinBox::Units::kNone, button_background=0x1dea428, type=UI::SpinBox::Type::kSmall, step_size=1, big_step_size=10)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/spinbox.cc:171
#7 0x0000000000f4c6ee in FullscreenMenuOptions::FullscreenMenuOptions (this=0x1c06fa0, opt=...)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_fsmenu/options.cc:234
#8 0x0000000000f51430 in OptionsCtrl::OptionsCtrl (this=0x7fffffffdf10, s=...)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_fsmenu/options.cc:539
#9 0x0000000000c3136e in WLApplication::mainmenu (this=0x1960b10) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/wlapplication.cc:1013
#10 0x0000000000c2de4c in WLApplication::run (this=0x1960b10) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/wlapplication.cc:444
#11 0x0000000000c2c4c1 in main (argc=1, argv=0x7fffffffe588) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/main.cc:49

review: Needs Fixing
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2007. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/205821093.
Appveyor build 1843. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1653460_panel_init_width-1843.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The spinbox now only layouts itself if it has size, so that should fix it.

review: Needs Resubmitting
Revision history for this message
kaputtnik (franku) wrote :

Crash when accessing "About Widelands":

This is Widelands Version bzr8310[bug-1653460-panel-init-width] (Debug)
[...]
widelands: /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/panel.cc:243: void UI::Panel::set_size(int, int): Assertion `nw >= 0' failed.

Thread 1 "widelands" received signal SIGABRT, Aborted.
0x00007ffff513b04f in raise () from /usr/lib/libc.so.6
(gdb) backtrace
#0 0x00007ffff513b04f in raise () from /usr/lib/libc.so.6
#1 0x00007ffff513c47a in abort () from /usr/lib/libc.so.6
#2 0x00007ffff5133ea7 in __assert_fail_base () from /usr/lib/libc.so.6
#3 0x00007ffff5133f52 in __assert_fail () from /usr/lib/libc.so.6
#4 0x0000000000edafe4 in UI::Panel::set_size (this=0x1d47c20, nw=-10, nh=-49)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/panel.cc:243
#5 0x0000000000ecb775 in UI::FileViewPanel::update_tab_size (this=0x7fffffffce00, index=0)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/fileview_panel.cc:68
#6 0x0000000000ecb8c6 in UI::FileViewPanel::layout (this=0x7fffffffce00)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/fileview_panel.cc:83
#7 0x0000000000ef656b in UI::TabPanel::update_desired_size (this=0x7fffffffce00)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/tabpanel.cc:158
#8 0x0000000000ef6971 in UI::TabPanel::add_tab (this=0x7fffffffce00, width=74, name="about_0", title="Readme", pic=0x21ed330, tooltip_text="", panel=0x1d59920)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/tabpanel.cc:207
#9 0x0000000000ef6660 in UI::TabPanel::add (this=0x7fffffffce00, name="about_0", title="Readme", panel=0x1d59920, tooltip_text="")
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/tabpanel.cc:170
#10 0x0000000000ecb41f in UI::FileViewPanel::add_tab (this=0x7fffffffce00, lua_script="txts/README.lua")
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_basic/fileview_panel.cc:59
#11 0x0000000000f019e8 in FullscreenMenuAbout::FullscreenMenuAbout (this=0x7fffffffca80)
    at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/ui_fsmenu/about.cc:39
#12 0x0000000000c3138f in WLApplication::mainmenu (this=0x1960b10) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/wlapplication.cc:1017
#13 0x0000000000c2de4c in WLApplication::run (this=0x1960b10) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/wlapplication.cc:444
#14 0x0000000000c2c4c1 in main (argc=1, argv=0x7fffffffe5b8) at /home/kaputtnik/Quellcode/widelands-repo/bug-1653460-panel-init-width/src/main.cc:49

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

Similar crash happens in game if a building wants to be dismantled.

Backtrace then: https://bugs.launchpad.net/widelands/+bug/1653460/+attachment/4828491/+files/backtrace

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for these. I'll have a look if we can get rid of the failures - we might have some underlying bugs here that nobody noticed. If not, I'll remove the new assertions.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Should be all fixed now.

review: Needs Resubmitting
Revision history for this message
kaputtnik (franku) wrote :

Looks good :-)

review: Approve (testing)
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2021. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/206920952.
Appveyor build 1857. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1653460_panel_init_width-1857.

Revision history for this message
kaputtnik (franku) wrote :

Can't test it right now, but is it likely that this merge proposal also fixes bug 1664052?

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Works for me,

played this for some while,
feels a bit differnet but no more assertions or such.

Had no time for a code review, though

review: Approve (compile, test)
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

OK found no obvious code flaws,
I played this in several config for some time withou any harm.

@bunnybot merge

review: Approve (code review)
Revision history for this message
GunChleoc (gunchleoc) wrote :

Replied to your question. Thanks for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/box.cc'
2--- src/ui_basic/box.cc 2017-02-25 13:27:40 +0000
3+++ src/ui_basic/box.cc 2017-03-02 08:46:01 +0000
4@@ -98,7 +98,7 @@
5 int maxbreadth = mindesiredbreadth_;
6
7 for (uint32_t idx = 0; idx < items_.size(); ++idx) {
8- int depth, breadth;
9+ int depth, breadth = 0;
10 get_item_desired_size(idx, &depth, &breadth);
11
12 totaldepth += depth;
13@@ -137,7 +137,7 @@
14 int totaldepth = 0;
15
16 for (size_t idx = 0; idx < items_.size(); ++idx) {
17- int depth, unused;
18+ int depth, unused = 0;
19 get_item_desired_size(idx, &depth, &unused);
20 totaldepth += depth;
21 }
22@@ -203,7 +203,7 @@
23 for (size_t idx = 0; idx < items_.size(); ++idx)
24 if (items_[idx].fillspace) {
25 assert(infspace_count > 0);
26- items_[idx].assigned_var_depth = (max_depths - totaldepth) / infspace_count;
27+ items_[idx].assigned_var_depth = std::max(0, (max_depths - totaldepth) / infspace_count);
28 totaldepth += items_[idx].assigned_var_depth;
29 infspace_count--;
30 }
31@@ -217,11 +217,12 @@
32
33 uint32_t totaldepth = 0;
34 uint32_t totalbreadth = orientation_ == Horizontal ? get_inner_h() : get_inner_w();
35- if (scrollbar_)
36+ if (scrollbar_ && scrollbar_->is_enabled()) {
37 totalbreadth -= Scrollbar::kSize;
38+ }
39
40 for (uint32_t idx = 0; idx < items_.size(); ++idx) {
41- int depth, breadth;
42+ int depth, breadth = 0;
43 get_item_size(idx, &depth, &breadth);
44
45 if (items_[idx].type == Item::ItemPanel) {
46@@ -371,7 +372,7 @@
47
48 switch (it.type) {
49 case Item::ItemPanel: {
50- int32_t breadth, maxbreadth;
51+ int32_t breadth, maxbreadth = 0;
52
53 if (orientation_ == Horizontal) {
54 breadth = it.u.panel.panel->get_inner_h();
55
56=== modified file 'src/ui_basic/fileview_panel.cc'
57--- src/ui_basic/fileview_panel.cc 2017-01-25 18:55:59 +0000
58+++ src/ui_basic/fileview_panel.cc 2017-03-02 08:46:01 +0000
59@@ -70,6 +70,9 @@
60
61 void FileViewPanel::layout() {
62 assert(boxes_.size() == textviews_.size());
63+ if (get_inner_w() == 0 && get_inner_h() == 0) {
64+ return;
65+ }
66
67 // If there is a border, we have less space for the contents
68 contents_width_ =
69
70=== modified file 'src/ui_basic/listselect.cc'
71--- src/ui_basic/listselect.cc 2017-02-23 19:38:51 +0000
72+++ src/ui_basic/listselect.cc 2017-03-02 08:46:01 +0000
73@@ -69,10 +69,9 @@
74 scrollbar_.moved.connect(boost::bind(&BaseListselect::set_scrollpos, this, _1));
75
76 if (selection_mode_ == ListselectLayout::kShowCheck) {
77- int pic_h;
78 check_pic_ = g_gr->images().get("images/ui_basic/list_selected.png");
79 max_pic_width_ = check_pic_->width();
80- pic_h = check_pic_->height();
81+ int pic_h = check_pic_->height();
82 if (pic_h > lineheight_)
83 lineheight_ = pic_h;
84 } else {
85
86=== modified file 'src/ui_basic/multilineeditbox.cc'
87--- src/ui_basic/multilineeditbox.cc 2017-02-23 17:58:25 +0000
88+++ src/ui_basic/multilineeditbox.cc 2017-03-02 08:46:01 +0000
89@@ -303,7 +303,7 @@
90 if (d_->cursor_pos < d_->text.size()) {
91 d_->refresh_ww();
92
93- uint32_t cursorline, cursorpos;
94+ uint32_t cursorline, cursorpos = 0;
95 d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
96
97 if (cursorline + 1 < d_->ww.nrlines()) {
98@@ -332,7 +332,7 @@
99 if (d_->cursor_pos > 0) {
100 d_->refresh_ww();
101
102- uint32_t cursorline, cursorpos;
103+ uint32_t cursorline, cursorpos = 0;
104 d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
105
106 if (cursorline > 0) {
107@@ -361,7 +361,7 @@
108 } else {
109 d_->refresh_ww();
110
111- uint32_t cursorline, cursorpos;
112+ uint32_t cursorline, cursorpos = 0;
113 d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
114
115 d_->set_cursor_pos(d_->ww.line_offset(cursorline));
116@@ -379,7 +379,7 @@
117 } else {
118 d_->refresh_ww();
119
120- uint32_t cursorline, cursorpos;
121+ uint32_t cursorline, cursorpos = 0;
122 d_->ww.calc_wrapped_pos(d_->cursor_pos, cursorline, cursorpos);
123
124 if (cursorline + 1 < d_->ww.nrlines())
125@@ -488,7 +488,7 @@
126 void MultilineEditbox::Data::scroll_cursor_into_view() {
127 refresh_ww();
128
129- uint32_t cursorline, cursorpos;
130+ uint32_t cursorline, cursorpos = 0;
131 ww.calc_wrapped_pos(cursor_pos, cursorline, cursorpos);
132
133 int32_t lineheight = textstyle.font->height();
134
135=== modified file 'src/ui_basic/multilinetextarea.cc'
136--- src/ui_basic/multilinetextarea.cc 2017-02-23 19:38:51 +0000
137+++ src/ui_basic/multilinetextarea.cc 2017-03-02 08:46:01 +0000
138@@ -79,7 +79,7 @@
139 * and adjust scrollbar settings accordingly.
140 */
141 void MultilineTextarea::recompute() {
142- uint32_t height;
143+ int height = 0;
144
145 // We wrap the text twice. We need to do this to account for the presence/absence of the
146 // scollbar.
147
148=== modified file 'src/ui_basic/panel.cc'
149--- src/ui_basic/panel.cc 2017-01-25 18:55:59 +0000
150+++ src/ui_basic/panel.cc 2017-03-02 08:46:01 +0000
151@@ -240,8 +240,12 @@
152 if (nw == w_ && nh == h_)
153 return;
154
155- w_ = nw;
156- h_ = nh;
157+ assert(nw >= 0);
158+ assert(nh >= 0);
159+
160+ // Make sure that we never get negative width/height in release builds.
161+ w_ = std::max(0, nw);
162+ h_ = std::max(0, nh);
163
164 if (parent_)
165 move_inside_parent();
166@@ -282,9 +286,12 @@
167
168 assert(w < 3000);
169 assert(h < 3000);
170+ assert(w >= 0);
171+ assert(h >= 0);
172
173- desired_w_ = w;
174- desired_h_ = h;
175+ // Make sure that we never get negative width/height in release builds.
176+ desired_w_ = std::max(0, w);
177+ desired_h_ = std::max(0, h);
178 if (!get_layout_toplevel() && parent_) {
179 parent_->update_desired_size();
180 } else {
181@@ -351,6 +358,7 @@
182 * Set the size of the inner area (total area minus border)
183 */
184 void Panel::set_inner_size(int const nw, int const nh) {
185+ assert(nw >= 0 && nh >= 0);
186 set_size(nw + lborder_ + rborder_, nh + tborder_ + bborder_);
187 }
188
189@@ -366,6 +374,15 @@
190 bborder_ = b;
191 }
192
193+int Panel::get_inner_w() const {
194+ assert(w_ == 0 || lborder_ + rborder_ <= w_);
195+ return (w_ == 0 ? 0 : w_ - (lborder_ + rborder_));
196+}
197+int Panel::get_inner_h() const {
198+ assert(h_ == 0 || tborder_ + bborder_ <= h_);
199+ return (h_ == 0 ? 0 : h_ - (tborder_ + bborder_));
200+}
201+
202 /**
203 * Make this panel the top-most panel in the parent's Z-order.
204 */
205
206=== modified file 'src/ui_basic/panel.h'
207--- src/ui_basic/panel.h 2017-01-25 18:55:59 +0000
208+++ src/ui_basic/panel.h 2017-03-02 08:46:01 +0000
209@@ -180,14 +180,8 @@
210 return bborder_;
211 }
212
213- int get_inner_w() const {
214- assert(lborder_ + rborder_ <= w_);
215- return w_ - (lborder_ + rborder_);
216- }
217- int get_inner_h() const {
218- assert(tborder_ + bborder_ <= h_);
219- return h_ - (tborder_ + bborder_);
220- }
221+ int get_inner_w() const;
222+ int get_inner_h() const;
223
224 const Panel* get_next_sibling() const {
225 return next_;
226
227=== modified file 'src/ui_basic/scrollbar.cc'
228--- src/ui_basic/scrollbar.cc 2017-01-25 18:55:59 +0000
229+++ src/ui_basic/scrollbar.cc 2017-03-02 08:46:01 +0000
230@@ -130,7 +130,7 @@
231 }
232
233 Scrollbar::Area Scrollbar::get_area_for_point(int32_t x, int32_t y) {
234- int32_t extent;
235+ int32_t extent = 0;
236
237 // Out of panel
238 if (x < 0 || x >= static_cast<int32_t>(get_w()) || y < 0 || y >= static_cast<int32_t>(get_h()))
239
240=== modified file 'src/ui_basic/spinbox.cc'
241--- src/ui_basic/spinbox.cc 2017-02-25 11:17:28 +0000
242+++ src/ui_basic/spinbox.cc 2017-03-02 08:46:01 +0000
243@@ -178,23 +178,24 @@
244 }
245
246 void SpinBox::layout() {
247- // Only do the checks if we have a unit width, so we can have 0 in the constructor
248- // and set the dimensions later.
249- if (unit_width_ > 0) {
250- // 40 is an ad hoc width estimate for the MultilineTextarea scrollbar + a bit of text.
251- if (!sbi_->label->get_text().empty() && (get_w() + padding_) <= unit_width_ - 40) {
252- throw wexception("SpinBox: Overall width %d must be bigger than unit width %d + %d * %d + "
253- "40 for padding",
254- get_w(), unit_width_, number_of_paddings_, padding_);
255- }
256-
257- if (unit_width_ < (type_ == SpinBox::Type::kBig ? 7 * button_height_ : 3 * button_height_)) {
258- log("Not enough space to draw spinbox \"%s\".\n"
259- "Width %d is smaller than required width %d."
260- "Please report as a bug.\n",
261- sbi_->label->get_text().c_str(), unit_width_,
262- (type_ == SpinBox::Type::kBig ? 7 * button_height_ : 3 * button_height_));
263- }
264+ // Do not layout if the size hasn't been set yet.
265+ if (get_w() == 0 && get_h() == 0) {
266+ return;
267+ }
268+
269+ // 40 is an ad hoc width estimate for the MultilineTextarea scrollbar + a bit of text.
270+ if (!sbi_->label->get_text().empty() && (get_w() + padding_) <= unit_width_ - 40) {
271+ throw wexception("SpinBox: Overall width %d must be bigger than unit width %d + %d * %d + "
272+ "40 for padding",
273+ get_w(), unit_width_, number_of_paddings_, padding_);
274+ }
275+
276+ if (unit_width_ < (type_ == SpinBox::Type::kBig ? 7 * button_height_ : 3 * button_height_)) {
277+ log("Not enough space to draw spinbox \"%s\".\n"
278+ "Width %d is smaller than required width %d."
279+ "Please report as a bug.\n",
280+ sbi_->label->get_text().c_str(), unit_width_,
281+ (type_ == SpinBox::Type::kBig ? 7 * button_height_ : 3 * button_height_));
282 }
283
284 // 10 is arbitrary, the actual height will be set by the Multilinetextarea itself
285
286=== modified file 'src/ui_basic/table.cc'
287--- src/ui_basic/table.cc 2017-02-26 11:57:15 +0000
288+++ src/ui_basic/table.cc 2017-03-02 08:46:01 +0000
289@@ -108,7 +108,7 @@
290 // If there would be existing entries, they would not get the new column.
291 assert(size() == 0);
292
293- uint32_t complete_width = 0;
294+ int complete_width = 0;
295 for (const Column& col : columns_) {
296 complete_width += col.width;
297 }
298@@ -133,7 +133,6 @@
299 flexible_column_ = columns_.size() - 1;
300 }
301 }
302- layout();
303 }
304
305 void Table<void*>::set_column_title(uint8_t const col, const std::string& title) {
306@@ -209,8 +208,7 @@
307 if (entries == 0) {
308 entries = size();
309 }
310- int tablewidth;
311- int tableheight;
312+ int tablewidth, tableheight = 0;
313 get_desired_size(&tablewidth, &tableheight);
314 tableheight = headerheight_ + 2 + get_lineheight() * entries;
315 set_desired_size(tablewidth, tableheight);
316@@ -606,15 +604,13 @@
317
318 // Find a column to resize
319 size_t resizeable_column = std::numeric_limits<size_t>::max();
320- if (flexible_column_ != std::numeric_limits<size_t>::max()) {
321+ if (flexible_column_ < columns_.size()) {
322 resizeable_column = flexible_column_;
323 } else {
324 // Use the widest column
325- int all_columns_width = scrollbar_ && scrollbar_->is_enabled() ? scrollbar_->get_w() : 0;
326 uint32_t widest_width = columns_[resizeable_column].width;
327 for (size_t i = 1; i < columns_.size(); ++i) {
328 const uint32_t width = columns_[i].width;
329- all_columns_width += width;
330 if (width > widest_width) {
331 widest_width = width;
332 resizeable_column = i;
333@@ -630,8 +626,9 @@
334 }
335 if (all_columns_width != get_w()) {
336 Column& column = columns_.at(resizeable_column);
337- column.width = column.width + get_w() - all_columns_width;
338+ column.width = std::max(0, column.width + get_w() - all_columns_width);
339 column.btn->set_size(column.width, column.btn->get_h());
340+
341 int offset = 0;
342 for (const auto& col : columns_) {
343 col.btn->set_pos(Vector2i(offset, col.btn->get_y()));
344
345=== modified file 'src/ui_basic/table.h'
346--- src/ui_basic/table.h 2017-02-26 11:57:15 +0000
347+++ src/ui_basic/table.h 2017-03-02 08:46:01 +0000
348@@ -184,6 +184,8 @@
349 void set_column_title(uint8_t col, const std::string& title);
350 void set_column_compare(uint8_t col, const CompareFn& fn);
351
352+ void layout() override;
353+
354 void clear();
355 void set_sort_column(uint8_t const col) {
356 assert(col < columns_.size());
357@@ -280,11 +282,10 @@
358 private:
359 bool default_compare_string(uint32_t column, uint32_t a, uint32_t b);
360 bool sort_helper(uint32_t a, uint32_t b);
361- void layout() override;
362
363 struct Column {
364 Button* btn;
365- uint32_t width;
366+ int width;
367 Align alignment;
368 CompareFn compare;
369 };
370@@ -293,8 +294,8 @@
371 static const int32_t ms_darken_value = -20;
372
373 Columns columns_;
374- uint32_t total_width_;
375- uint32_t headerheight_;
376+ int total_width_;
377+ const uint32_t headerheight_;
378 int32_t lineheight_;
379 const Image* button_background_;
380 Scrollbar* scrollbar_;
381
382=== modified file 'src/ui_basic/tabpanel.cc'
383--- src/ui_basic/tabpanel.cc 2017-02-23 19:38:51 +0000
384+++ src/ui_basic/tabpanel.cc 2017-03-02 08:46:01 +0000
385@@ -139,7 +139,7 @@
386 // size of contents
387 if (active_ < tabs_.size()) {
388 Panel* const panel = tabs_[active_]->panel;
389- int panelw, panelh;
390+ int panelw, panelh = 0;
391
392 panel->get_desired_size(&panelw, &panelh);
393 // TODO(unknown): the panel might be bigger -> add a scrollbar in that case
394@@ -167,7 +167,7 @@
395 const std::string& tooltip_text) {
396 const Image* pic = UI::g_fh1->render(as_uifont(title));
397 return add_tab(std::max(kTabPanelButtonHeight, pic->width() + 2 * kTabPanelTextMargin), name,
398- title, pic, tooltip_text, panel);
399+ title, pic, tooltip_text, panel);
400 }
401
402 /**
403
404=== modified file 'src/ui_basic/textarea.cc'
405--- src/ui_basic/textarea.cc 2017-02-23 19:38:51 +0000
406+++ src/ui_basic/textarea.cc 2017-03-02 08:46:01 +0000
407@@ -163,7 +163,7 @@
408 int32_t y = get_y();
409
410 update_desired_size();
411- int w, h;
412+ int w, h = 0;
413 get_desired_size(&w, &h);
414
415 switch (align_) {
416
417=== modified file 'src/ui_basic/window.cc'
418--- src/ui_basic/window.cc 2017-02-24 10:21:37 +0000
419+++ src/ui_basic/window.cc 2017-03-02 08:46:01 +0000
420@@ -128,7 +128,7 @@
421 */
422 void Window::update_desired_size() {
423 if (center_panel_ && !is_minimal_) {
424- int innerw, innerh;
425+ int innerw, innerh = 0;
426 center_panel_->get_desired_size(&innerw, &innerh);
427 set_desired_size(
428 innerw + get_lborder() + get_rborder(), innerh + get_tborder() + get_bborder());
429
430=== modified file 'src/ui_fsmenu/campaign_select.cc'
431--- src/ui_fsmenu/campaign_select.cc 2017-02-26 11:57:15 +0000
432+++ src/ui_fsmenu/campaign_select.cc 2017-03-02 08:46:01 +0000
433@@ -358,6 +358,7 @@
434
435 void FullscreenMenuCampaignMapSelect::layout() {
436 // TODO(GunChleoc): Implement when we have box layout for the details.
437+ table_.layout();
438 }
439
440 std::string FullscreenMenuCampaignMapSelect::get_map() {
441
442=== modified file 'src/ui_fsmenu/internet_lobby.cc'
443--- src/ui_fsmenu/internet_lobby.cc 2017-02-23 19:38:51 +0000
444+++ src/ui_fsmenu/internet_lobby.cc 2017-03-02 08:46:01 +0000
445@@ -153,6 +153,7 @@
446
447 void FullscreenMenuInternetLobby::layout() {
448 // TODO(GunChleoc): Box layout and then implement
449+ clientsonline_list_.layout();
450 }
451
452 /// think function of the UI (main loop)
453
454=== modified file 'src/ui_fsmenu/loadgame.cc'
455--- src/ui_fsmenu/loadgame.cc 2017-02-26 11:57:15 +0000
456+++ src/ui_fsmenu/loadgame.cc 2017-03-02 08:46:01 +0000
457@@ -188,6 +188,7 @@
458 ta_mapname_.set_tooltip(_("The map that this game is based on"));
459 delete_.set_tooltip(_("Delete this game"));
460 }
461+ set_thinks(false);
462 minimap_icon_.set_visible(false);
463
464 back_.sigclicked.connect(boost::bind(&FullscreenMenuLoadGame::clicked_back, boost::ref(*this)));
465@@ -240,6 +241,7 @@
466
467 void FullscreenMenuLoadGame::layout() {
468 // TODO(GunChleoc): Implement when we have box layout for the details.
469+ table_.layout();
470 }
471
472 void FullscreenMenuLoadGame::think() {
473
474=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
475--- src/ui_fsmenu/netsetup_lan.cc 2017-02-23 19:38:51 +0000
476+++ src/ui_fsmenu/netsetup_lan.cc 2017-03-02 08:46:01 +0000
477@@ -126,6 +126,7 @@
478
479 void FullscreenMenuNetSetupLAN::layout() {
480 // TODO(GunChleoc): Box layout and then implement
481+ opengames.layout();
482 }
483
484 void FullscreenMenuNetSetupLAN::think() {
485
486=== modified file 'src/wui/actionconfirm.cc'
487--- src/wui/actionconfirm.cc 2017-02-26 11:00:07 +0000
488+++ src/wui/actionconfirm.cc 2017-03-02 08:46:01 +0000
489@@ -220,7 +220,7 @@
490 : ActionConfirm(parent,
491 _("Dismantle building?"),
492 _("Do you really want to dismantle this building?"),
493- building) {
494+ building) {
495 // Nothing special to do
496 }
497
498
499=== modified file 'src/wui/game_message_menu.cc'
500--- src/wui/game_message_menu.cc 2017-02-26 11:57:15 +0000
501+++ src/wui/game_message_menu.cc 2017-03-02 08:46:01 +0000
502@@ -152,6 +152,7 @@
503 ColTimeSent, boost::bind(&GameMessageMenu::compare_time_sent, this, _1, _2));
504
505 list->set_sort_column(ColTimeSent);
506+ list->layout();
507
508 set_can_focus(true);
509 focus();
510
511=== modified file 'src/wui/game_summary.cc'
512--- src/wui/game_summary.cc 2017-02-25 13:27:40 +0000
513+++ src/wui/game_summary.cc 2017-03-02 08:46:01 +0000
514@@ -208,6 +208,7 @@
515 if (!players_status.empty()) {
516 players_table_->select(current_player_position);
517 }
518+ players_table_->layout();
519 }
520
521 void GameSummaryScreen::continue_clicked() {
522
523=== modified file 'src/wui/maptable.cc'
524--- src/wui/maptable.cc 2017-02-26 11:57:15 +0000
525+++ src/wui/maptable.cc 2017-03-02 08:46:01 +0000
526@@ -76,4 +76,5 @@
527 }
528 }
529 sort();
530+ layout();
531 }

Subscribers

People subscribed via source and target branches

to status/vote changes: