Merge lp:~gerboland/qtubuntu/stricter-enums into lp:qtubuntu

Proposed by Gerry Boland
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 347
Merged at revision: 347
Proposed branch: lp:~gerboland/qtubuntu/stricter-enums
Merge into: lp:qtubuntu
Prerequisite: lp:~dandrader/qtubuntu/loggingFixes
Diff against target: 192 lines (+23/-40)
4 files modified
src/ubuntumirclient/input.cpp (+14/-25)
src/ubuntumirclient/screen.cpp (+1/-6)
src/ubuntumirclient/screenobserver.cpp (+1/-1)
src/ubuntumirclient/window.cpp (+7/-8)
To merge this branch: bzr merge lp:~gerboland/qtubuntu/stricter-enums
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Unity8 CI Bot continuous-integration Approve
Review via email: mp+305819@code.launchpad.net

This proposal supersedes a proposal from 2016-09-14.

Commit message

Stricter enum use, avoid default switch case

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

Otherwise I'm ok with it.

Revision history for this message
Daniel d'Andrada (dandrader) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:345
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/115/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2867
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2895
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2753/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2753
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2753/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/115/rebuild

review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Rebased & resubmitted on top of lp:~dandrader/qtubuntu/loggingFixes

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:347
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/116/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2885
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2913
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2771/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2771
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2771/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/116/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/input.cpp'
2--- src/ubuntumirclient/input.cpp 2016-09-15 11:13:33 +0000
3+++ src/ubuntumirclient/input.cpp 2016-09-15 11:13:33 +0000
4@@ -209,32 +209,31 @@
5 switch (t)
6 {
7 case mir_event_type_key:
8- return "mir_event_type_key";
9+ return "key";
10 case mir_event_type_motion:
11- return "mir_event_type_motion";
12+ return "motion";
13 case mir_event_type_surface:
14- return "mir_event_type_surface";
15+ return "surface";
16 case mir_event_type_resize:
17- return "mir_event_type_resize";
18+ return "resize";
19 case mir_event_type_prompt_session_state_change:
20- return "mir_event_type_prompt_session_state_change";
21+ return "prompt_session_state_change";
22 case mir_event_type_orientation:
23- return "mir_event_type_orientation";
24+ return "orientation";
25 case mir_event_type_close_surface:
26- return "mir_event_type_close_surface";
27+ return "close_surface";
28 case mir_event_type_input:
29- return "mir_event_type_input";
30+ return "input";
31 case mir_event_type_keymap:
32- return "mir_event_type_keymap";
33+ return "keymap";
34 case mir_event_type_input_configuration:
35- return "mir_event_type_input_configuration";
36+ return "input_configuration";
37 case mir_event_type_surface_output:
38- return "mir_event_type_surface_output";
39+ return "surface_output";
40 case mir_event_type_input_device_state:
41- return "mir_event_type_input_device_state";
42+ return "input_device_state";
43 }
44-
45- return "unknown/invalid";
46+ Q_UNREACHABLE();
47 }
48
49 void UbuntuInput::customEvent(QEvent* event)
50@@ -340,8 +339,6 @@
51 case mir_input_event_type_pointer:
52 dispatchPointerEvent(window, ev);
53 break;
54- default:
55- break;
56 }
57 }
58
59@@ -383,7 +380,6 @@
60 touchPoint.state = Qt::TouchPointReleased;
61 break;
62 case mir_touch_action_change:
63- default:
64 touchPoint.state = Qt::TouchPointMoved;
65 }
66
67@@ -543,8 +539,6 @@
68 case mir_pointer_action_leave:
69 QWindowSystemInterface::handleLeaveEvent(window);
70 break;
71- default:
72- qCDebug(ubuntumirclient, "Unrecognized pointer event");
73 }
74 }
75
76@@ -553,19 +547,14 @@
77 switch (orientation) {
78 case mir_orientation_normal:
79 return "Normal";
80- break;
81 case mir_orientation_left:
82 return "Left";
83- break;
84 case mir_orientation_inverted:
85 return "Inverted";
86- break;
87 case mir_orientation_right:
88 return "Right";
89- break;
90- default:
91- return "INVALID!";
92 }
93+ Q_UNREACHABLE();
94 }
95
96 void UbuntuInput::dispatchOrientationEvent(QWindow *window, const MirOrientationEvent *event)
97
98=== modified file 'src/ubuntumirclient/screen.cpp'
99--- src/ubuntumirclient/screen.cpp 2016-04-28 14:09:54 +0000
100+++ src/ubuntumirclient/screen.cpp 2016-09-15 11:13:33 +0000
101@@ -46,9 +46,8 @@
102 return "inverted portrait";
103 case Qt::InvertedLandscapeOrientation:
104 return "inverted landscape";
105- default:
106- return "INVALID!";
107 }
108+ Q_UNREACHABLE();
109 }
110
111 const QEvent::Type OrientationChangeEvent::mType =
112@@ -97,10 +96,6 @@
113 Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation;
114 break;
115 }
116- default: {
117- qCDebug(ubuntumirclient, "UbuntuScreen::customEvent - Unknown orientation.");
118- return;
119- }
120 }
121
122 // Raise the event signal so that client apps know the orientation changed
123
124=== modified file 'src/ubuntumirclient/screenobserver.cpp'
125--- src/ubuntumirclient/screenobserver.cpp 2016-04-28 14:09:54 +0000
126+++ src/ubuntumirclient/screenobserver.cpp 2016-09-15 11:13:33 +0000
127@@ -47,7 +47,7 @@
128 case mir_form_factor_tv: return "tv";
129 case mir_form_factor_projector: return "projector";
130 }
131- return "";
132+ Q_UNREACHABLE();
133 }
134 } // anonymous namespace
135
136
137=== modified file 'src/ubuntumirclient/window.cpp'
138--- src/ubuntumirclient/window.cpp 2016-09-15 11:13:33 +0000
139+++ src/ubuntumirclient/window.cpp 2016-09-15 11:13:33 +0000
140@@ -81,9 +81,8 @@
141 return "Minimized";
142 case Qt::WindowActive:
143 return "Active";
144- default:
145- return "!?";
146 }
147+ Q_UNREACHABLE();
148 }
149
150 const char *mirSurfaceStateToStr(MirSurfaceState surfaceState)
151@@ -97,8 +96,9 @@
152 case mir_surface_state_fullscreen: return "fullscreen";
153 case mir_surface_state_horizmaximized: return "horizmaximized";
154 case mir_surface_state_hidden: return "hidden";
155- default: return "!?";
156+ case mir_surface_states: Q_UNREACHABLE();
157 }
158+ Q_UNREACHABLE();
159 }
160
161 const char *mirPixelFormatToStr(MirPixelFormat pixelFormat)
162@@ -114,15 +114,16 @@
163 case mir_pixel_format_rgb_565: return "RGB565";
164 case mir_pixel_format_rgba_5551: return "RGBA5551";
165 case mir_pixel_format_rgba_4444: return "RGBA4444";
166- case mir_pixel_formats:
167- default: return "???";
168+ case mir_pixel_formats: Q_UNREACHABLE();
169 }
170+ Q_UNREACHABLE();
171 }
172
173 MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state)
174 {
175 switch (state) {
176 case Qt::WindowNoState:
177+ case Qt::WindowActive:
178 return mir_surface_state_restored;
179 case Qt::WindowFullScreen:
180 return mir_surface_state_fullscreen;
181@@ -130,10 +131,8 @@
182 return mir_surface_state_maximized;
183 case Qt::WindowMinimized:
184 return mir_surface_state_minimized;
185- default:
186- qCWarning(ubuntumirclient, "Unexpected Qt::WindowState: %d", state);
187- return mir_surface_state_restored;
188 }
189+ return mir_surface_state_unknown; // should never be reached
190 }
191
192 WId makeId()

Subscribers

People subscribed via source and target branches