Merge lp:~hjd/widelands/assert-to-exception into lp:widelands

Proposed by Hans Joachim Desserud
Status: Merged
Merged at revision: 7224
Proposed branch: lp:~hjd/widelands/assert-to-exception
Merge into: lp:widelands
Diff against target: 22 lines (+2/-3)
1 file modified
src/wui/interactive_base.cc (+2/-3)
To merge this branch: bzr merge lp:~hjd/widelands/assert-to-exception
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+238824@code.launchpad.net

Description of the change

As mentioned, turn this assert into an exception so that it will also work with release builds and resolve unused assignment issue.

Btw, this seems rather small and independent so I believe it can be refactored into a separate method getWareInfoIndex(workarea_info.size()). However, ::size_type seems to take whichever class/type the map use so I don't know what the return class should be for this new method.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/interactive_base.cc'
2--- src/wui/interactive_base.cc 2014-10-11 16:03:18 +0000
3+++ src/wui/interactive_base.cc 2014-10-19 16:26:43 +0000
4@@ -253,7 +253,7 @@
5 OverlayManager::JobId InteractiveBase::show_work_area
6 (const WorkareaInfo & workarea_info, Widelands::Coords coords)
7 {
8- uint8_t workareas_nrs = workarea_info.size();
9+ const uint8_t workareas_nrs = workarea_info.size();
10 WorkareaInfo::size_type wa_index;
11 switch (workareas_nrs) {
12 case 0: return 0; // no workarea
13@@ -261,8 +261,7 @@
14 case 2: wa_index = 3; break;
15 case 3: wa_index = 0; break;
16 default:
17- wa_index = 0;
18- assert(false);
19+ throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs);
20 break;
21 }
22 Widelands::Map & map = m_egbase.map();

Subscribers

People subscribed via source and target branches

to status/vote changes: