Merge lp:~widelands-dev/widelands/fix_huge_boxes into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 7750
Proposed branch: lp:~widelands-dev/widelands/fix_huge_boxes
Merge into: lp:widelands
Diff against target: 125 lines (+19/-25)
3 files modified
src/ui_basic/box.cc (+13/-17)
src/ui_basic/box.h (+3/-2)
src/ui_basic/listselect.cc (+3/-6)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fix_huge_boxes
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+284176@code.launchpad.net

Commit message

Fix ptr = 0 to *ptr = 0

Description of the change

Fixes huge boxes.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Hi, I am bunnybot (https://github.com/widelands/bunnybot).

I am keeping the source branch lp:~widelands-dev/widelands/fix_huge_boxes mirrored to https://github.com/widelands/widelands/tree/_widelands_dev_widelands_fix_huge_boxes

You can give me commands by starting a line with @bunnybot <command>. I understand:
 merge: Merges the source branch into the target branch, closing the merge proposal. I will use the proposed commit message if it is set.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 419. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/105250971.
Appveyor build 320. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fix_huge_boxes-320.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Isn't it fun that 0 still evaluates to NULL...

Code LGTM and tested. Travis also looks clean.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 419. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/105250971.
Appveyor build 320. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fix_huge_boxes-320.

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 2016-01-27 08:06:40 +0000
3+++ src/ui_basic/box.cc 2016-01-27 19:16:27 +0000
4@@ -134,14 +134,14 @@
5 int totaldepth = 0;
6
7 for (size_t idx = 0; idx < m_items.size(); ++idx) {
8- int depth, tmp;
9- get_item_desired_size(idx, &depth, &tmp);
10-
11+ int depth, unused;
12+ get_item_desired_size(idx, &depth, &unused);
13 totaldepth += depth;
14 }
15
16- if (!m_items.empty())
17+ if (!m_items.empty()) {
18 totaldepth += (m_items.size() - 1) * m_inner_spacing;
19+ }
20
21 bool needscrollbar = false;
22 if (m_orientation == Horizontal) {
23@@ -170,27 +170,24 @@
24 sb_h = get_inner_h();
25 pagesize = get_inner_h() - Scrollbar::Size;
26 }
27- if (!m_scrollbar) {
28- m_scrollbar = new Scrollbar
29- (this, sb_x, sb_y, sb_w,
30- sb_h, m_orientation == Horizontal);
31+ if (m_scrollbar == nullptr) {
32+ m_scrollbar.reset(
33+ new Scrollbar(this, sb_x, sb_y, sb_w, sb_h, m_orientation == Horizontal));
34 m_scrollbar->moved.connect(boost::bind(&Box::scrollbar_moved, this, _1));
35 } else {
36 m_scrollbar->set_pos(Point(sb_x, sb_y));
37 m_scrollbar->set_size(sb_w, sb_h);
38 }
39-
40 m_scrollbar->set_steps(totaldepth - pagesize);
41 m_scrollbar->set_singlestepsize(Scrollbar::Size);
42 m_scrollbar->set_pagesize(pagesize);
43 } else {
44- delete m_scrollbar;
45- m_scrollbar = nullptr;
46+ m_scrollbar.reset();
47 }
48
49 // Second pass: Count number of infinite spaces
50- uint32_t infspace_count = 0;
51- for (uint32_t idx = 0; idx < m_items.size(); ++idx)
52+ int infspace_count = 0;
53+ for (size_t idx = 0; idx < m_items.size(); ++idx)
54 if (m_items[idx].fillspace)
55 infspace_count++;
56
57@@ -198,9 +195,8 @@
58 // avoid having some pixels left at the end due to rounding errors, we
59 // divide the remaining space by the number of remaining infinite
60 // spaces every time, and not just one.
61- uint32_t max_depths =
62- m_orientation == Horizontal ? get_inner_w() : get_inner_h();
63- for (uint32_t idx = 0; idx < m_items.size(); ++idx)
64+ int max_depths = m_orientation == Horizontal ? get_inner_w() : get_inner_h();
65+ for (size_t idx = 0; idx < m_items.size(); ++idx)
66 if (m_items[idx].fillspace) {
67 assert(infspace_count > 0);
68 m_items[idx].assigned_var_depth =
69@@ -334,7 +330,7 @@
70
71 case Item::ItemSpace:
72 *depth = it.u.space;
73- breadth = 0;
74+ *breadth = 0;
75 break;
76 }
77 }
78
79=== modified file 'src/ui_basic/box.h'
80--- src/ui_basic/box.h 2016-01-27 08:06:40 +0000
81+++ src/ui_basic/box.h 2016-01-27 19:16:27 +0000
82@@ -20,12 +20,13 @@
83 #ifndef WL_UI_BASIC_BOX_H
84 #define WL_UI_BASIC_BOX_H
85
86+#include <memory>
87 #include <vector>
88
89 #include "ui_basic/panel.h"
90+#include "ui_basic/scrollbar.h"
91
92 namespace UI {
93-struct Scrollbar;
94
95 /**
96 * A layouting panel that holds a number of child panels.
97@@ -104,7 +105,7 @@
98 };
99
100 bool m_scrolling;
101- Scrollbar * m_scrollbar;
102+ std::unique_ptr<Scrollbar> m_scrollbar;
103 uint32_t m_orientation;
104 uint32_t m_mindesiredbreadth;
105 uint32_t m_inner_spacing;
106
107=== modified file 'src/ui_basic/listselect.cc'
108--- src/ui_basic/listselect.cc 2015-11-08 17:31:06 +0000
109+++ src/ui_basic/listselect.cc 2016-01-27 19:16:27 +0000
110@@ -355,13 +355,10 @@
111 dst.brighten_rect(Rect(Point(0, 0), get_w(), get_h()), ms_darken_value);
112
113 while (idx < m_entry_records.size()) {
114- assert
115- (get_h()
116- <
117- static_cast<int32_t>(std::numeric_limits<int32_t>::max()));
118-
119- if (y >= static_cast<int32_t>(get_h()))
120+ assert(get_h() < std::numeric_limits<int32_t>::max());
121+ if (y >= get_h()) {
122 break;
123+ }
124
125 const EntryRecord & er = *m_entry_records[idx];
126

Subscribers

People subscribed via source and target branches

to status/vote changes: