Merge lp:~alan-griffiths/qtmir/new-migrate-to-mir-Server-API into lp:qtmir
- new-migrate-to-mir-Server-API
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | 290 |
Merged at revision: | 291 |
Proposed branch: | lp:~alan-griffiths/qtmir/new-migrate-to-mir-Server-API |
Merge into: | lp:qtmir |
Diff against target: |
489 lines (+128/-139) 10 files modified
src/platforms/mirserver/display.cpp (+1/-1) src/platforms/mirserver/display.h (+3/-3) src/platforms/mirserver/miropenglcontext.cpp (+1/-1) src/platforms/mirserver/miropenglcontext.h (+3/-3) src/platforms/mirserver/mirserverconfiguration.cpp (+40/-77) src/platforms/mirserver/mirserverconfiguration.h (+4/-14) src/platforms/mirserver/mirserverintegration.cpp (+0/-12) src/platforms/mirserver/qmirserver.cpp (+34/-0) src/platforms/mirserver/qmirserver.h (+17/-8) tests/modules/common/qtmir_test.h (+25/-20) |
To merge this branch: | bzr merge lp:~alan-griffiths/qtmir/new-migrate-to-mir-Server-API |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+243177@code.launchpad.net |
Commit message
Migration of qtmir from the legacy Mir API
Description of the change
Migration of qtmir from the legacy Mir API
This is somewhat minimalist - there's possibilities of code cleanup and improved naming. But it moves the dependencies over to the mir::Server based APIs and seems to run OK on krillin/15.04(r39).
I'll look at the cleanup work next week.
Alan Griffiths (alan-griffiths) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:288
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 289. By Alan Griffiths
-
Fix initialization order in tests
Alan Griffiths (alan-griffiths) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:289
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
I approve of the code-changes, but testing on a desktop machine, it crashes on startup: http://
Gerry Boland (gerboland) wrote : | # |
For more info, I just checked out this branch on my vivid machine, built it, installed it, and tried to log into a unity8 desktop session. The backtrace was what I managed to get manually, may not be actual issue.
- 290. By Alan Griffiths
-
Fix startup race condition
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:290
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
Also tested on with desktop U8
Gerry Boland (gerboland) wrote : | # |
Yep, working nicely now, thanks
* Did you perform an exploratory manual test run of the code change and any related functionality?
Y
* Did CI run pass? If not, please explain why.
Y
Preview Diff
1 | === modified file 'src/platforms/mirserver/display.cpp' | |||
2 | --- src/platforms/mirserver/display.cpp 2014-10-16 18:27:04 +0000 | |||
3 | +++ src/platforms/mirserver/display.cpp 2014-12-02 12:30:45 +0000 | |||
4 | @@ -27,7 +27,7 @@ | |||
5 | 27 | 27 | ||
6 | 28 | // TODO: Listen for display changes and update the list accordingly | 28 | // TODO: Listen for display changes and update the list accordingly |
7 | 29 | 29 | ||
9 | 30 | Display::Display(const QSharedPointer<mir::DefaultServerConfiguration> &config, QObject *parent) | 30 | Display::Display(const QSharedPointer<mir::Server> &config, QObject *parent) |
10 | 31 | : QObject(parent) | 31 | : QObject(parent) |
11 | 32 | , m_mirConfig(config) | 32 | , m_mirConfig(config) |
12 | 33 | { | 33 | { |
13 | 34 | 34 | ||
14 | === modified file 'src/platforms/mirserver/display.h' | |||
15 | --- src/platforms/mirserver/display.h 2014-10-10 18:52:44 +0000 | |||
16 | +++ src/platforms/mirserver/display.h 2014-12-02 12:30:45 +0000 | |||
17 | @@ -23,20 +23,20 @@ | |||
18 | 23 | #include <qpa/qplatformscreen.h> | 23 | #include <qpa/qplatformscreen.h> |
19 | 24 | 24 | ||
20 | 25 | #include "mir/graphics/display.h" | 25 | #include "mir/graphics/display.h" |
22 | 26 | #include "mir/default_server_configuration.h" | 26 | #include "mir/server.h" |
23 | 27 | 27 | ||
24 | 28 | class Display : public QObject | 28 | class Display : public QObject |
25 | 29 | { | 29 | { |
26 | 30 | Q_OBJECT | 30 | Q_OBJECT |
27 | 31 | public: | 31 | public: |
29 | 32 | Display(const QSharedPointer<mir::DefaultServerConfiguration> &config, QObject *parent = 0); | 32 | Display(const QSharedPointer<mir::Server> &config, QObject *parent = 0); |
30 | 33 | ~Display(); | 33 | ~Display(); |
31 | 34 | 34 | ||
32 | 35 | QList<QPlatformScreen *> screens() const { return m_screens; } | 35 | QList<QPlatformScreen *> screens() const { return m_screens; } |
33 | 36 | 36 | ||
34 | 37 | private: | 37 | private: |
35 | 38 | QList<QPlatformScreen *> m_screens; | 38 | QList<QPlatformScreen *> m_screens; |
37 | 39 | const QSharedPointer<mir::DefaultServerConfiguration> m_mirConfig; | 39 | const QSharedPointer<mir::Server> m_mirConfig; |
38 | 40 | }; | 40 | }; |
39 | 41 | 41 | ||
40 | 42 | #endif // DISPLAY_H | 42 | #endif // DISPLAY_H |
41 | 43 | 43 | ||
42 | === modified file 'src/platforms/mirserver/miropenglcontext.cpp' | |||
43 | --- src/platforms/mirserver/miropenglcontext.cpp 2014-07-15 11:30:11 +0000 | |||
44 | +++ src/platforms/mirserver/miropenglcontext.cpp 2014-12-02 12:30:45 +0000 | |||
45 | @@ -35,7 +35,7 @@ | |||
46 | 35 | // The Mir "Display" generates a shared GL context for all DisplayBuffers | 35 | // The Mir "Display" generates a shared GL context for all DisplayBuffers |
47 | 36 | // (i.e. individual display output buffers) to use as a common base context. | 36 | // (i.e. individual display output buffers) to use as a common base context. |
48 | 37 | 37 | ||
50 | 38 | MirOpenGLContext::MirOpenGLContext(const QSharedPointer<mir::DefaultServerConfiguration> &config, const QSurfaceFormat &format) | 38 | MirOpenGLContext::MirOpenGLContext(const QSharedPointer<mir::Server> &config, const QSurfaceFormat &format) |
51 | 39 | : m_mirConfig(config) | 39 | : m_mirConfig(config) |
52 | 40 | #if GL_DEBUG | 40 | #if GL_DEBUG |
53 | 41 | , m_logger(new QOpenGLDebugLogger(this)) | 41 | , m_logger(new QOpenGLDebugLogger(this)) |
54 | 42 | 42 | ||
55 | === modified file 'src/platforms/mirserver/miropenglcontext.h' | |||
56 | --- src/platforms/mirserver/miropenglcontext.h 2014-05-16 16:45:00 +0000 | |||
57 | +++ src/platforms/mirserver/miropenglcontext.h 2014-12-02 12:30:45 +0000 | |||
58 | @@ -27,13 +27,13 @@ | |||
59 | 27 | #include <QOpenGLDebugLogger> | 27 | #include <QOpenGLDebugLogger> |
60 | 28 | #endif | 28 | #endif |
61 | 29 | 29 | ||
63 | 30 | #include <mir/default_server_configuration.h> | 30 | #include <mir/server.h> |
64 | 31 | 31 | ||
65 | 32 | class MirOpenGLContext : public QObject, public QPlatformOpenGLContext | 32 | class MirOpenGLContext : public QObject, public QPlatformOpenGLContext |
66 | 33 | { | 33 | { |
67 | 34 | Q_OBJECT | 34 | Q_OBJECT |
68 | 35 | public: | 35 | public: |
70 | 36 | MirOpenGLContext(const QSharedPointer<mir::DefaultServerConfiguration> &, const QSurfaceFormat &); | 36 | MirOpenGLContext(const QSharedPointer<mir::Server> &, const QSurfaceFormat &); |
71 | 37 | ~MirOpenGLContext() = default; | 37 | ~MirOpenGLContext() = default; |
72 | 38 | 38 | ||
73 | 39 | QSurfaceFormat format() const override; | 39 | QSurfaceFormat format() const override; |
74 | @@ -52,7 +52,7 @@ | |||
75 | 52 | #endif | 52 | #endif |
76 | 53 | 53 | ||
77 | 54 | private: | 54 | private: |
79 | 55 | const QSharedPointer<mir::DefaultServerConfiguration> m_mirConfig; | 55 | const QSharedPointer<mir::Server> m_mirConfig; |
80 | 56 | QSurfaceFormat m_format; | 56 | QSurfaceFormat m_format; |
81 | 57 | #if GL_DEBUG | 57 | #if GL_DEBUG |
82 | 58 | QOpenGLDebugLogger *m_logger; | 58 | QOpenGLDebugLogger *m_logger; |
83 | 59 | 59 | ||
84 | === modified file 'src/platforms/mirserver/mirserverconfiguration.cpp' | |||
85 | --- src/platforms/mirserver/mirserverconfiguration.cpp 2014-09-17 12:48:54 +0000 | |||
86 | +++ src/platforms/mirserver/mirserverconfiguration.cpp 2014-12-02 12:30:45 +0000 | |||
87 | @@ -14,6 +14,8 @@ | |||
88 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
89 | 15 | */ | 15 | */ |
90 | 16 | 16 | ||
91 | 17 | #include <QCoreApplication> | ||
92 | 18 | |||
93 | 17 | #include "mirserverconfiguration.h" | 19 | #include "mirserverconfiguration.h" |
94 | 18 | 20 | ||
95 | 19 | // local | 21 | // local |
96 | @@ -50,115 +52,76 @@ | |||
97 | 50 | 52 | ||
98 | 51 | MirServerConfiguration::MirServerConfiguration(int argc, char const* argv[], QObject* parent) | 53 | MirServerConfiguration::MirServerConfiguration(int argc, char const* argv[], QObject* parent) |
99 | 52 | : QObject(parent) | 54 | : QObject(parent) |
100 | 53 | , DefaultServerConfiguration(std::make_shared<mo::DefaultConfiguration>(argc, argv, &ignore_unparsed_arguments)) | ||
101 | 54 | { | 55 | { |
104 | 55 | qCDebug(QTMIR_MIR_MESSAGES) << "MirServerConfiguration created"; | 56 | set_command_line_handler(&ignore_unparsed_arguments); |
105 | 56 | } | 57 | set_command_line(argc, argv); |
106 | 57 | 58 | ||
112 | 58 | std::shared_ptr<ms::PlacementStrategy> | 59 | override_the_placement_strategy([this] |
108 | 59 | MirServerConfiguration::the_placement_strategy() | ||
109 | 60 | { | ||
110 | 61 | return shell_placement_strategy( | ||
111 | 62 | [this] | ||
113 | 63 | { | 60 | { |
114 | 64 | return std::make_shared<MirPlacementStrategy>(the_shell_display_layout()); | 61 | return std::make_shared<MirPlacementStrategy>(the_shell_display_layout()); |
115 | 65 | }); | 62 | }); |
116 | 66 | } | ||
117 | 67 | 63 | ||
123 | 68 | std::shared_ptr<ms::SessionListener> | 64 | override_the_session_listener([] |
119 | 69 | MirServerConfiguration::the_session_listener() | ||
120 | 70 | { | ||
121 | 71 | return session_listener( | ||
122 | 72 | [this] | ||
124 | 73 | { | 65 | { |
125 | 74 | return std::make_shared<SessionListener>(); | 66 | return std::make_shared<SessionListener>(); |
126 | 75 | }); | 67 | }); |
127 | 76 | } | ||
128 | 77 | 68 | ||
134 | 78 | std::shared_ptr<ms::PromptSessionListener> | 69 | override_the_prompt_session_listener([] |
130 | 79 | MirServerConfiguration::the_prompt_session_listener() | ||
131 | 80 | { | ||
132 | 81 | return prompt_session_listener( | ||
133 | 82 | [this] | ||
135 | 83 | { | 70 | { |
136 | 84 | return std::make_shared<PromptSessionListener>(); | 71 | return std::make_shared<PromptSessionListener>(); |
137 | 85 | }); | 72 | }); |
138 | 86 | } | ||
139 | 87 | 73 | ||
145 | 88 | std::shared_ptr<ms::SurfaceConfigurator> | 74 | override_the_surface_configurator([] |
141 | 89 | MirServerConfiguration::the_surface_configurator() | ||
142 | 90 | { | ||
143 | 91 | return surface_configurator( | ||
144 | 92 | [this]() | ||
146 | 93 | { | 75 | { |
147 | 94 | return std::make_shared<SurfaceConfigurator>(); | 76 | return std::make_shared<SurfaceConfigurator>(); |
148 | 95 | }); | 77 | }); |
166 | 96 | } | 78 | |
167 | 97 | 79 | override_the_session_authorizer([] | |
168 | 98 | std::shared_ptr<mir::frontend::SessionAuthorizer> | 80 | { |
169 | 99 | MirServerConfiguration::the_session_authorizer() | 81 | return std::make_shared<SessionAuthorizer>(); |
170 | 100 | { | 82 | }); |
171 | 101 | return session_authorizer( | 83 | |
172 | 102 | [] | 84 | override_the_compositor([] |
156 | 103 | { | ||
157 | 104 | return std::make_shared<SessionAuthorizer>(); | ||
158 | 105 | }); | ||
159 | 106 | } | ||
160 | 107 | |||
161 | 108 | std::shared_ptr<mir::compositor::Compositor> | ||
162 | 109 | MirServerConfiguration::the_compositor() | ||
163 | 110 | { | ||
164 | 111 | return compositor( | ||
165 | 112 | [this]() | ||
173 | 113 | { | 85 | { |
174 | 114 | return std::make_shared<QtCompositor>(); | 86 | return std::make_shared<QtCompositor>(); |
175 | 115 | }); | 87 | }); |
194 | 116 | } | 88 | |
195 | 117 | 89 | override_the_input_dispatcher([] | |
196 | 118 | std::shared_ptr<mir::input::InputDispatcher> | 90 | { |
197 | 119 | MirServerConfiguration::the_input_dispatcher() | 91 | return std::make_shared<QtEventFeeder>(); |
198 | 120 | { | 92 | }); |
199 | 121 | return input_dispatcher( | 93 | |
200 | 122 | [this]() | 94 | override_the_gl_config([] |
201 | 123 | { | 95 | { |
184 | 124 | return std::make_shared<QtEventFeeder>(); | ||
185 | 125 | }); | ||
186 | 126 | } | ||
187 | 127 | |||
188 | 128 | std::shared_ptr<mir::graphics::GLConfig> | ||
189 | 129 | MirServerConfiguration::the_gl_config() | ||
190 | 130 | { | ||
191 | 131 | return gl_config( | ||
192 | 132 | [this]() | ||
193 | 133 | { | ||
202 | 134 | #ifdef QTMIR_USE_OPENGL | 96 | #ifdef QTMIR_USE_OPENGL |
205 | 135 | // Should desktop-GL be desired, need to bind that API before a context is created | 97 | // Should desktop-GL be desired, need to bind that API before a context is created |
206 | 136 | eglBindAPI(EGL_OPENGL_API); | 98 | eglBindAPI(EGL_OPENGL_API); |
207 | 137 | #endif | 99 | #endif |
211 | 138 | return std::make_shared<MirGLConfig>(); | 100 | return std::make_shared<MirGLConfig>(); |
212 | 139 | }); | 101 | }); |
210 | 140 | } | ||
213 | 141 | 102 | ||
219 | 142 | std::shared_ptr<mir::ServerStatusListener> | 103 | override_the_server_status_listener([] |
215 | 143 | MirServerConfiguration::the_server_status_listener() | ||
216 | 144 | { | ||
217 | 145 | return server_status_listener( | ||
218 | 146 | []() | ||
220 | 147 | { | 104 | { |
221 | 148 | return std::make_shared<MirServerStatusListener>(); | 105 | return std::make_shared<MirServerStatusListener>(); |
222 | 149 | }); | 106 | }); |
223 | 150 | } | ||
224 | 151 | 107 | ||
230 | 152 | std::shared_ptr<mir::shell::FocusSetter> | 108 | override_the_shell_focus_setter([] |
226 | 153 | MirServerConfiguration::the_shell_focus_setter() | ||
227 | 154 | { | ||
228 | 155 | return shell_focus_setter( | ||
229 | 156 | [this] | ||
231 | 157 | { | 109 | { |
232 | 158 | return std::make_shared<FocusSetter>(); | 110 | return std::make_shared<FocusSetter>(); |
233 | 159 | }); | 111 | }); |
234 | 112 | |||
235 | 113 | set_terminator([&](int) | ||
236 | 114 | { | ||
237 | 115 | qDebug() << "Signal caught by Mir, stopping Mir server.."; | ||
238 | 116 | QCoreApplication::quit(); | ||
239 | 117 | }); | ||
240 | 118 | |||
241 | 119 | apply_settings(); | ||
242 | 120 | |||
243 | 121 | qCDebug(QTMIR_MIR_MESSAGES) << "MirServerConfiguration created"; | ||
244 | 160 | } | 122 | } |
245 | 161 | 123 | ||
246 | 124 | |||
247 | 162 | /************************************ Shell side ************************************/ | 125 | /************************************ Shell side ************************************/ |
248 | 163 | 126 | ||
249 | 164 | // | 127 | // |
250 | 165 | 128 | ||
251 | === modified file 'src/platforms/mirserver/mirserverconfiguration.h' | |||
252 | --- src/platforms/mirserver/mirserverconfiguration.h 2014-09-17 12:34:40 +0000 | |||
253 | +++ src/platforms/mirserver/mirserverconfiguration.h 2014-12-02 12:30:45 +0000 | |||
254 | @@ -18,7 +18,7 @@ | |||
255 | 18 | #define MIRSERVERCONFIGURATION_H | 18 | #define MIRSERVERCONFIGURATION_H |
256 | 19 | 19 | ||
257 | 20 | #include <QObject> | 20 | #include <QObject> |
259 | 21 | #include <mir/default_server_configuration.h> | 21 | #include <mir/server.h> |
260 | 22 | 22 | ||
261 | 23 | class QtEventFeeder; | 23 | class QtEventFeeder; |
262 | 24 | class SessionListener; | 24 | class SessionListener; |
263 | @@ -26,7 +26,9 @@ | |||
264 | 26 | class SurfaceConfigurator; | 26 | class SurfaceConfigurator; |
265 | 27 | class PromptSessionListener; | 27 | class PromptSessionListener; |
266 | 28 | 28 | ||
268 | 29 | class MirServerConfiguration : public QObject, public mir::DefaultServerConfiguration | 29 | // We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing) |
269 | 30 | // calling initialization functions before MirServerConfiguration is constructed. | ||
270 | 31 | class MirServerConfiguration : public QObject, public virtual mir::Server | ||
271 | 30 | { | 32 | { |
272 | 31 | Q_OBJECT | 33 | Q_OBJECT |
273 | 32 | 34 | ||
274 | @@ -39,18 +41,6 @@ | |||
275 | 39 | MirServerConfiguration(int argc, char const* argv[], QObject* parent = 0); | 41 | MirServerConfiguration(int argc, char const* argv[], QObject* parent = 0); |
276 | 40 | ~MirServerConfiguration() = default; | 42 | ~MirServerConfiguration() = default; |
277 | 41 | 43 | ||
278 | 42 | /* mir specific */ | ||
279 | 43 | std::shared_ptr<mir::compositor::Compositor> the_compositor() override; | ||
280 | 44 | std::shared_ptr<mir::scene::PlacementStrategy> the_placement_strategy() override; | ||
281 | 45 | std::shared_ptr<mir::scene::SessionListener> the_session_listener() override; | ||
282 | 46 | std::shared_ptr<mir::scene::PromptSessionListener> the_prompt_session_listener() override; | ||
283 | 47 | std::shared_ptr<mir::scene::SurfaceConfigurator> the_surface_configurator() override; | ||
284 | 48 | std::shared_ptr<mir::frontend::SessionAuthorizer> the_session_authorizer() override; | ||
285 | 49 | std::shared_ptr<mir::input::InputDispatcher> the_input_dispatcher() override; | ||
286 | 50 | std::shared_ptr<mir::graphics::GLConfig> the_gl_config() override; | ||
287 | 51 | std::shared_ptr<mir::ServerStatusListener> the_server_status_listener() override; | ||
288 | 52 | std::shared_ptr<mir::shell::FocusSetter> the_shell_focus_setter() override; | ||
289 | 53 | |||
290 | 54 | /* qt specific */ | 44 | /* qt specific */ |
291 | 55 | // getters | 45 | // getters |
292 | 56 | SessionAuthorizer *sessionAuthorizer(); | 46 | SessionAuthorizer *sessionAuthorizer(); |
293 | 57 | 47 | ||
294 | === modified file 'src/platforms/mirserver/mirserverintegration.cpp' | |||
295 | --- src/platforms/mirserver/mirserverintegration.cpp 2014-10-01 18:42:26 +0000 | |||
296 | +++ src/platforms/mirserver/mirserverintegration.cpp 2014-12-02 12:30:45 +0000 | |||
297 | @@ -42,7 +42,6 @@ | |||
298 | 42 | // Mir | 42 | // Mir |
299 | 43 | #include <mir/graphics/display.h> | 43 | #include <mir/graphics/display.h> |
300 | 44 | #include <mir/graphics/display_buffer.h> | 44 | #include <mir/graphics/display_buffer.h> |
301 | 45 | #include <mir/main_loop.h> | ||
302 | 46 | 45 | ||
303 | 47 | // std | 46 | // std |
304 | 48 | #include <csignal> | 47 | #include <csignal> |
305 | @@ -179,17 +178,6 @@ | |||
306 | 179 | for (QPlatformScreen *screen : m_display->screens()) | 178 | for (QPlatformScreen *screen : m_display->screens()) |
307 | 180 | screenAdded(screen); | 179 | screenAdded(screen); |
308 | 181 | 180 | ||
309 | 182 | // install signal handler into the Mir event loop | ||
310 | 183 | auto mainLoop = m_mirConfig->the_main_loop(); | ||
311 | 184 | |||
312 | 185 | mainLoop->register_signal_handler( | ||
313 | 186 | {SIGINT, SIGTERM}, | ||
314 | 187 | [&](int) | ||
315 | 188 | { | ||
316 | 189 | qDebug() << "Signal caught by Mir, stopping Mir server.."; | ||
317 | 190 | QCoreApplication::quit(); | ||
318 | 191 | }); | ||
319 | 192 | |||
320 | 193 | m_clipboard->setupDBusService(); | 181 | m_clipboard->setupDBusService(); |
321 | 194 | } | 182 | } |
322 | 195 | 183 | ||
323 | 196 | 184 | ||
324 | === modified file 'src/platforms/mirserver/qmirserver.cpp' | |||
325 | --- src/platforms/mirserver/qmirserver.cpp 2014-05-16 16:45:00 +0000 | |||
326 | +++ src/platforms/mirserver/qmirserver.cpp 2014-12-02 12:30:45 +0000 | |||
327 | @@ -19,10 +19,38 @@ | |||
328 | 19 | #include <QCoreApplication> | 19 | #include <QCoreApplication> |
329 | 20 | #include <QDebug> | 20 | #include <QDebug> |
330 | 21 | 21 | ||
331 | 22 | #include <mir/main_loop.h> | ||
332 | 23 | |||
333 | 22 | // local | 24 | // local |
334 | 23 | #include "qmirserver.h" | 25 | #include "qmirserver.h" |
335 | 24 | 26 | ||
336 | 25 | 27 | ||
337 | 28 | void MirServerWorker::run() | ||
338 | 29 | { | ||
339 | 30 | auto const main_loop = config->the_main_loop(); | ||
340 | 31 | // By enqueuing the notification code in the main loop, we are | ||
341 | 32 | // ensuring that the server has really and fully started before | ||
342 | 33 | // leaving wait_for_startup(). | ||
343 | 34 | main_loop->enqueue( | ||
344 | 35 | this, | ||
345 | 36 | [&] | ||
346 | 37 | { | ||
347 | 38 | std::lock_guard<std::mutex> lock(mutex); | ||
348 | 39 | mir_running = true; | ||
349 | 40 | started_cv.notify_one(); | ||
350 | 41 | }); | ||
351 | 42 | |||
352 | 43 | config->run(); | ||
353 | 44 | Q_EMIT stopped(); | ||
354 | 45 | } | ||
355 | 46 | |||
356 | 47 | bool MirServerWorker::wait_for_mir_startup() | ||
357 | 48 | { | ||
358 | 49 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
359 | 50 | started_cv.wait_for(lock, std::chrono::seconds{10}, [&]{ return mir_running; }); | ||
360 | 51 | return mir_running; | ||
361 | 52 | } | ||
362 | 53 | |||
363 | 26 | QMirServer::QMirServer(const QSharedPointer<MirServerConfiguration> &config, QObject *parent) | 54 | QMirServer::QMirServer(const QSharedPointer<MirServerConfiguration> &config, QObject *parent) |
364 | 27 | : QObject(parent) | 55 | : QObject(parent) |
365 | 28 | , m_mirServer(new MirServerWorker(config)) | 56 | , m_mirServer(new MirServerWorker(config)) |
366 | @@ -37,6 +65,12 @@ | |||
367 | 37 | 65 | ||
368 | 38 | m_mirThread.start(QThread::TimeCriticalPriority); | 66 | m_mirThread.start(QThread::TimeCriticalPriority); |
369 | 39 | Q_EMIT run(); | 67 | Q_EMIT run(); |
370 | 68 | |||
371 | 69 | if (!m_mirServer->wait_for_mir_startup()) | ||
372 | 70 | { | ||
373 | 71 | qCritical() << "ERROR: QMirServer - Mir failed to start"; | ||
374 | 72 | QCoreApplication::quit(); | ||
375 | 73 | } | ||
376 | 40 | } | 74 | } |
377 | 41 | 75 | ||
378 | 42 | QMirServer::~QMirServer() | 76 | QMirServer::~QMirServer() |
379 | 43 | 77 | ||
380 | === modified file 'src/platforms/mirserver/qmirserver.h' | |||
381 | --- src/platforms/mirserver/qmirserver.h 2014-05-16 16:45:00 +0000 | |||
382 | +++ src/platforms/mirserver/qmirserver.h 2014-12-02 12:30:45 +0000 | |||
383 | @@ -22,28 +22,37 @@ | |||
384 | 22 | #include <QThread> | 22 | #include <QThread> |
385 | 23 | #include <QSharedPointer> | 23 | #include <QSharedPointer> |
386 | 24 | 24 | ||
387 | 25 | // Mir | ||
388 | 26 | #include <mir/display_server.h> | ||
389 | 27 | |||
390 | 28 | // local | 25 | // local |
391 | 29 | #include "mirserverconfiguration.h" | 26 | #include "mirserverconfiguration.h" |
392 | 30 | 27 | ||
395 | 31 | // Wrap mir::DisplayServer with QObject, so it can be controlled via QThread | 28 | #include <condition_variable> |
396 | 32 | class MirServerWorker : public QObject, public mir::DisplayServer | 29 | #include <mutex> |
397 | 30 | |||
398 | 31 | // Wrap mir::Server with QObject, so it can be controlled via QThread | ||
399 | 32 | class MirServerWorker : public QObject | ||
400 | 33 | { | 33 | { |
401 | 34 | Q_OBJECT | 34 | Q_OBJECT |
402 | 35 | 35 | ||
403 | 36 | public: | 36 | public: |
404 | 37 | MirServerWorker(const QSharedPointer<MirServerConfiguration> &config) | 37 | MirServerWorker(const QSharedPointer<MirServerConfiguration> &config) |
406 | 38 | : mir::DisplayServer(*config.data()) | 38 | : config(config) |
407 | 39 | {} | 39 | {} |
408 | 40 | 40 | ||
409 | 41 | bool wait_for_mir_startup(); | ||
410 | 42 | |||
411 | 41 | Q_SIGNALS: | 43 | Q_SIGNALS: |
412 | 42 | void stopped(); | 44 | void stopped(); |
413 | 43 | 45 | ||
414 | 44 | public Q_SLOTS: | 46 | public Q_SLOTS: |
417 | 45 | void run() { mir::DisplayServer::run(); Q_EMIT stopped(); } | 47 | void run(); |
418 | 46 | void stop() { mir::DisplayServer::stop(); } | 48 | void stop() { config->stop(); } |
419 | 49 | |||
420 | 50 | private: | ||
421 | 51 | std::mutex mutex; | ||
422 | 52 | std::condition_variable started_cv; | ||
423 | 53 | bool mir_running{false}; | ||
424 | 54 | |||
425 | 55 | const QSharedPointer<MirServerConfiguration> config; | ||
426 | 47 | }; | 56 | }; |
427 | 48 | 57 | ||
428 | 49 | 58 | ||
429 | 50 | 59 | ||
430 | === modified file 'tests/modules/common/qtmir_test.h' | |||
431 | --- tests/modules/common/qtmir_test.h 2014-10-06 21:23:39 +0000 | |||
432 | +++ tests/modules/common/qtmir_test.h 2014-12-02 12:30:45 +0000 | |||
433 | @@ -41,31 +41,36 @@ | |||
434 | 41 | 41 | ||
435 | 42 | namespace qtmir { | 42 | namespace qtmir { |
436 | 43 | 43 | ||
438 | 44 | class FakeMirServerConfiguration: public MirServerConfiguration | 44 | // Initialization of mir::Server needed for by tests |
439 | 45 | class TestMirServerInit : virtual mir::Server | ||
440 | 45 | { | 46 | { |
441 | 47 | public: | ||
442 | 48 | TestMirServerInit() | ||
443 | 49 | { | ||
444 | 50 | override_the_prompt_session_manager( | ||
445 | 51 | [this]{ return the_mock_prompt_session_manager(); }); | ||
446 | 52 | } | ||
447 | 53 | |||
448 | 54 | std::shared_ptr<mir::scene::MockPromptSessionManager> the_mock_prompt_session_manager() | ||
449 | 55 | { | ||
450 | 56 | return mock_prompt_session_manager; | ||
451 | 57 | } | ||
452 | 58 | |||
453 | 59 | private: | ||
454 | 46 | typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager; | 60 | typedef testing::NiceMock<mir::scene::MockPromptSessionManager> StubPromptSessionManager; |
455 | 61 | std::shared_ptr<StubPromptSessionManager> const mock_prompt_session_manager | ||
456 | 62 | {std::make_shared<StubPromptSessionManager>()}; | ||
457 | 63 | }; | ||
458 | 64 | |||
459 | 65 | class FakeMirServerConfiguration: private TestMirServerInit, public MirServerConfiguration | ||
460 | 66 | { | ||
461 | 47 | public: | 67 | public: |
462 | 48 | FakeMirServerConfiguration() | 68 | FakeMirServerConfiguration() |
463 | 49 | : MirServerConfiguration(0, nullptr) | 69 | : MirServerConfiguration(0, nullptr) |
483 | 50 | , mock_prompt_session_manager(std::make_shared<StubPromptSessionManager>()) | 70 | { |
484 | 51 | { | 71 | } |
485 | 52 | } | 72 | |
486 | 53 | 73 | using TestMirServerInit::the_mock_prompt_session_manager; | |
468 | 54 | std::shared_ptr<ms::PromptSessionManager> the_prompt_session_manager() override | ||
469 | 55 | { | ||
470 | 56 | return prompt_session_manager([this]() | ||
471 | 57 | ->std::shared_ptr<ms::PromptSessionManager> | ||
472 | 58 | { | ||
473 | 59 | return the_mock_prompt_session_manager(); | ||
474 | 60 | }); | ||
475 | 61 | } | ||
476 | 62 | |||
477 | 63 | std::shared_ptr<StubPromptSessionManager> the_mock_prompt_session_manager() | ||
478 | 64 | { | ||
479 | 65 | return mock_prompt_session_manager; | ||
480 | 66 | } | ||
481 | 67 | |||
482 | 68 | std::shared_ptr<StubPromptSessionManager> mock_prompt_session_manager; | ||
487 | 69 | }; | 74 | }; |
488 | 70 | 75 | ||
489 | 71 | } // namespace qtmir | 76 | } // namespace qtmir |
* Are there any related MPs required for this MP to build/function as expected? Please list.
N
* Did you perform an exploratory manual test run of your code change and any related functionality?
Y
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A