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

Proposed by Gerry Boland
Status: Superseded
Proposed branch: lp:~gerboland/qtubuntu/stricter-enums
Merge into: lp:qtubuntu
Diff against target: 198 lines (+27/-38)
4 files modified
src/ubuntumirclient/input.cpp (+17/-22)
src/ubuntumirclient/screen.cpp (+1/-6)
src/ubuntumirclient/screenobserver.cpp (+1/-1)
src/ubuntumirclient/window.cpp (+8/-9)
To merge this branch: bzr merge lp:~gerboland/qtubuntu/stricter-enums
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Daniel d'Andrada (community) Needs Fixing
Review via email: mp+305716@code.launchpad.net

This proposal has been superseded by a proposal from 2016-09-15.

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 :
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Otherwise I'm ok with it.

Revision history for this message
Daniel d'Andrada (dandrader) :
review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

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)

Unmerged revisions

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

Subscribers

People subscribed via source and target branches