Merge lp:~gerboland/unity-mir/fix-shutdown-crash2 into lp:unity-mir

Proposed by Gerry Boland
Status: Merged
Approved by: Michał Sawicz
Approved revision: 197
Merged at revision: 201
Proposed branch: lp:~gerboland/unity-mir/fix-shutdown-crash2
Merge into: lp:unity-mir
Diff against target: 86 lines (+23/-20)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+22/-19)
src/modules/Unity/Application/application_manager.h (+1/-1)
To merge this branch: bzr merge lp:~gerboland/unity-mir/fix-shutdown-crash2
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+210427@code.launchpad.net

Commit message

ApplicationManager instance is owned & managed by the QML engine. Wrapping it with QSharedPointer causes shutdown crash due to double deletion. Resolve by removing the shared pointer wrapping.

I tried specifying C++ ownership of the ApplicationManager object to the QmlEngine, but it did not work.

Description of the change

Fixes shutdown crash of unity8 in latest developer image.

To reproduce the crash, in adb, simply run
  kill -SIGTERM `pidof unity8`

With this patch, shutdown is correct - just note that shutdown takes several seconds.

• Are there any related MPs required for this MP to build/function as expected? Please list.
No
• Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
• If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

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
Michał Sawicz (saviq) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes.

 * Did CI run pass? If not, please explain why.
Yes.

review: Approve
197. By Gerry Boland

Add big fixme

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/application_manager.cpp'
2--- src/modules/Unity/Application/application_manager.cpp 2014-03-11 03:40:49 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2014-03-11 15:36:35 +0000
4@@ -116,13 +116,13 @@
5 }
6 }
7
8-QSharedPointer<ApplicationManager> ApplicationManager::Factory::Factory::create()
9+ApplicationManager* ApplicationManager::Factory::Factory::create()
10 {
11 QMirServerApplication* mirServerApplication = dynamic_cast<QMirServerApplication*>(QCoreApplication::instance());
12 if (mirServerApplication == nullptr) {
13 LOG("Need to use QMirServerApplication");
14 QCoreApplication::quit();
15- return QSharedPointer<ApplicationManager>(nullptr);
16+ return nullptr;
17 }
18
19 ShellServerConfiguration * mirServer = mirServerApplication->server();
20@@ -133,33 +133,36 @@
21 QSharedPointer<TaskController> taskController(new TaskController(nullptr, appController));
22 QSharedPointer<DesktopFileReader::Factory> fileReaderFactory(new DesktopFileReader::Factory());
23 QSharedPointer<ProcInfo> procInfo(new ProcInfo());
24- QSharedPointer<ApplicationManager> appManager(
25- new ApplicationManager(
26- taskController,
27- fileReaderFactory,
28- procInfo,
29- mirServer->the_focus_controller(),
30- displaySize
31- )
32- );
33-
34-
35- connectToSessionListener(appManager.data(), mirServer->sessionListener());
36- connectToSessionAuthorizer(appManager.data(), mirServer->sessionAuthorizer());
37- connectToPlacementStrategy(appManager.data(), mirServer->placementStrategy());
38- connectToTaskController(appManager.data(), taskController.data());
39+
40+ // FIXME: We should use a QSharedPointer to wrap this ApplicationManager object, which requires us
41+ // to use the data() method to pass the raw pointer to the QML engine. However the QML engine appears
42+ // to take ownership of the object, and deletes it when it wants to. This conflicts with the purpose
43+ // of the QSharedPointer, and a double-delete results. Trying QQmlEngine::setObjectOwnership on the
44+ // object no effect, which it should. Need to investigate why.
45+ ApplicationManager* appManager = new ApplicationManager(
46+ taskController,
47+ fileReaderFactory,
48+ procInfo,
49+ mirServer->the_focus_controller(),
50+ displaySize
51+ );
52+
53+ connectToSessionListener(appManager, mirServer->sessionListener());
54+ connectToSessionAuthorizer(appManager, mirServer->sessionAuthorizer());
55+ connectToPlacementStrategy(appManager, mirServer->placementStrategy());
56+ connectToTaskController(appManager, taskController.data());
57
58 return appManager;
59 }
60
61 ApplicationManager* ApplicationManager::singleton()
62 {
63- static QSharedPointer<ApplicationManager> instance;
64+ static ApplicationManager* instance;
65 if (!instance) {
66 Factory appFactory;
67 instance = appFactory.create();
68 }
69- return instance.data();
70+ return instance;
71 }
72
73 ApplicationManager::ApplicationManager(
74
75=== modified file 'src/modules/Unity/Application/application_manager.h'
76--- src/modules/Unity/Application/application_manager.h 2014-03-11 03:40:26 +0000
77+++ src/modules/Unity/Application/application_manager.h 2014-03-11 15:36:35 +0000
78@@ -63,7 +63,7 @@
79 class Factory
80 {
81 public:
82- QSharedPointer<ApplicationManager> create();
83+ ApplicationManager* create();
84 };
85 // Mapping enums to Ubuntu Platform API enums.
86 enum Flag {

Subscribers

People subscribed via source and target branches