Merge lp:~aacid/unity-mir/waitforme into lp:unity-mir

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 115
Merged at revision: 120
Proposed branch: lp:~aacid/unity-mir/waitforme
Merge into: lp:unity-mir
Diff against target: 36 lines (+8/-2)
1 file modified
src/unity-mir/qmirserver.cpp (+8/-2)
To merge this branch: bzr merge lp:~aacid/unity-mir/waitforme
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+190716@code.launchpad.net

Commit message

Shut down QCoreApplication properly

If there's a Qt application running, tell it we're going away
Also, wait for the thread we created, otherwise the application will quit
while the thread is trying to shutdown

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

This tests strangely: sometimes Ctrl+C works immediately, sometimes only twice, and sometimes never. (note all tests done while screen active).

For example, if I wait for the greeter to appear, Ctrl+C works fine.
But if I hit Ctrl+C before that, I get a crash, sometimes with this:

pure virtual method called
terminate called without an active exception
Aborted (core dumped)

My theory on a cleaner fix is to not use run_mir at all, but copy most of run_mir's contents - just the threas start & stop bits, so leaving out the signal listening callback.

Then Qt should get the stop signal, do it's cleanup and exec() returns, and after that can stop all Mir's threads. It's a just a theory though.

This does improve the situation a lot. But can you try the above suggestion and let me know? If it doesn't work, I'll accept this.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Qt doesn't do any cleanup at all when gets the SIGTERM signal, just let's the kernel bring the app down, not sure it is what we want.

All the problems you have with you ctrl+c to early are imho mir not being able to cope well with a sigterm before it has "properly" started. Can be fixed later i'd say (not related to the call that has been plaging autopilot runs).

Revision history for this message
Gerry Boland (gerboland) wrote :

Oh and please alter commit message to make the first line a little more descriptive

Revision history for this message
Gerry Boland (gerboland) wrote :

> Qt doesn't do any cleanup at all when gets the SIGTERM signal, just let's the
> kernel bring the app down, not sure it is what we want.
>
> All the problems you have with you ctrl+c to early are imho mir not being able
> to cope well with a sigterm before it has "properly" started. Can be fixed
> later i'd say (not related to the call that has been plaging autopilot runs).
Fair enough

Revision history for this message
Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-mir/qmirserver.cpp'
2--- src/unity-mir/qmirserver.cpp 2013-09-09 22:59:02 +0000
3+++ src/unity-mir/qmirserver.cpp 2013-10-11 16:06:25 +0000
4@@ -23,6 +23,7 @@
5 #include <application/ubuntu_application_api_mirserver_priv.h>
6
7 // Qt
8+#include <QCoreApplication>
9 #include <QDebug>
10 #include <QThread>
11
12@@ -49,17 +50,22 @@
13 int argc = m_argc;
14 auto argv = m_argv;
15 auto config = new ShellServerConfiguration(m_argc, m_argv);
16+ std::thread *t;
17
18- mir::run_mir(*config, [config, &client, &argc, &argv](mir::DisplayServer&) {
19+ mir::run_mir(*config, [config, &client, &argc, &argv, &t](mir::DisplayServer&) {
20 ua_ui_mirserver_init(*config);
21
22 try {
23- new std::thread(client, argc, argv, config);
24+ t = new std::thread(client, argc, argv, config);
25 } catch (...) {
26 qDebug() << "Exception caught, quitting";
27 }
28 });
29 ua_ui_mirserver_finish();
30+ if (QCoreApplication::instance())
31+ QCoreApplication::instance()->quit();
32+ t->join();
33+
34 delete config;
35 return 0;
36 }

Subscribers

People subscribed via source and target branches