Merge lp:~tiagosh/messaging-app/fix_leaks_and_empty_view into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 518
Merged at revision: 529
Proposed branch: lp:~tiagosh/messaging-app/fix_leaks_and_empty_view
Merge into: lp:messaging-app
Diff against target: 304 lines (+128/-14)
9 files modified
src/messagingapplication.cpp (+5/-0)
src/messagingapplication.h (+1/-0)
src/qml/MMS/Previewer.qml (+11/-0)
src/qml/Messages.qml (+11/-7)
src/qml/MessagingBottomEdge.qml (+6/-0)
src/qml/MessagingPageLayout.qml (+13/-0)
src/qml/SettingsPage.qml (+28/-0)
src/qml/messaging-app.qml (+24/-7)
tests/qml/tst_MessagesView.qml (+29/-0)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/fix_leaks_and_empty_view
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+287247@code.launchpad.net

Commit message

- Fix some memory leaks
- Use another approach to decide when to display the empty state view
- Avoid removing pages when resizing the AdaptivePageLayout

Description of the change

- Fix some memory leaks
- Use another approach to decide when to display the empty state view
- Avoid removing pages when resizing the AdaptivePageLayout

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
518. By Tiago Salem Herrmann

fix qml test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve
519. By Tiago Salem Herrmann

avoid name collision

520. By Tiago Salem Herrmann

use a different name to avoid collision

521. By Tiago Salem Herrmann

reimplement findChild() to avoid test failure

522. By Tiago Salem Herrmann

destroy is asynchronous, so change the objectName

523. By Tiago Salem Herrmann

remove settings page from the stack

524. By Tiago Salem Herrmann

fix id of item

525. By Tiago Salem Herrmann

add 1ms delay to destroy

526. By Tiago Salem Herrmann

avoid redundant call

527. By Tiago Salem Herrmann

force destroy previewer views

528. By Tiago Salem Herrmann

merge trunk

529. By Tiago Salem Herrmann

only display 2 columns when width > units.gu(90)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/messagingapplication.cpp'
2--- src/messagingapplication.cpp 2016-02-10 17:01:02 +0000
3+++ src/messagingapplication.cpp 2016-03-17 21:07:09 +0000
4@@ -315,3 +315,8 @@
5 }
6 g_object_unref(G_OBJECT(notification));
7 }
8+
9+QObject *MessagingApplication::findMessagingChild(const QString &objectName)
10+{
11+ return m_view->rootObject()->findChild<QObject*>(objectName);
12+}
13
14=== modified file 'src/messagingapplication.h'
15--- src/messagingapplication.h 2015-11-24 18:09:55 +0000
16+++ src/messagingapplication.h 2016-03-17 21:07:09 +0000
17@@ -44,6 +44,7 @@
18 QString readTextFile(const QString &fileName);
19 QString fileMimeType(const QString &fileName);
20 void showNotificationMessage(const QString &message, const QString &icon = QString());
21+ QObject *findMessagingChild(const QString &objectName);
22
23 private Q_SLOTS:
24 void setFullscreen(bool fullscreen);
25
26=== modified file 'src/qml/MMS/Previewer.qml'
27--- src/qml/MMS/Previewer.qml 2016-02-01 20:10:42 +0000
28+++ src/qml/MMS/Previewer.qml 2016-03-17 21:07:09 +0000
29@@ -54,6 +54,17 @@
30 title: previewerPage.title
31 leadingActionBar {
32 id: leadingBar
33+ actions: [
34+ Action {
35+ name: "cancel"
36+ text: i18n.tr("Cancel")
37+ iconName: "back"
38+ shortcut: "Esc"
39+ onTriggered: {
40+ mainStack.removePage(previewerPage)
41+ }
42+ }
43+ ]
44 }
45
46 trailingActionBar {
47
48=== modified file 'src/qml/Messages.qml'
49--- src/qml/Messages.qml 2016-02-23 15:07:46 +0000
50+++ src/qml/Messages.qml 2016-03-17 21:07:09 +0000
51@@ -68,7 +68,6 @@
52 contactWatcher.isInteractive) ||
53 contactWatcher.alias === "") ? contactWatcher.identifier : contactWatcher.alias
54
55-
56 // When using this view from the bottom edge, we are not in the stack, so we need to push on top of the parent page
57 property var basePage: messages
58
59@@ -732,12 +731,6 @@
60 onTriggered: composeBar.addAttachments(sharedAttachmentsTransfer)
61 }
62
63- Component.onDestruction: {
64- if (!mainView.dualPanel && !startedFromBottomEdge) {
65- mainPage.displayedThreadIndex = -1
66- }
67- }
68-
69 onReady: {
70 isReady = true
71 if (participants.length === 0 && keyboardFocus)
72@@ -750,6 +743,17 @@
73 }
74 }
75
76+ // These fake items are used to track if there are instances loaded
77+ // on the second column because we have no access to the page stack
78+ Loader {
79+ sourceComponent: fakeItemComponent
80+ active: !startedFromBottomEdge
81+ }
82+ Component {
83+ id: fakeItemComponent
84+ Item { objectName:"fakeItem"}
85+ }
86+
87 Connections {
88 target: telepathyHelper
89 onSetupReady: {
90
91=== modified file 'src/qml/MessagingBottomEdge.qml'
92--- src/qml/MessagingBottomEdge.qml 2016-02-11 00:46:51 +0000
93+++ src/qml/MessagingBottomEdge.qml 2016-03-17 21:07:09 +0000
94@@ -5,6 +5,7 @@
95 id: bottomEdge
96
97 function commitWithProperties(properties) {
98+ _realPage.destroy()
99 _realPage = messagesComponent.createObject(null, properties)
100 commit()
101 }
102@@ -27,7 +28,12 @@
103 _realPage = messagesComponent.createObject(null)
104 }
105
106+ Component.onDestruction: {
107+ _realPage.destroy()
108+ }
109+
110 onCollapseCompleted: {
111+ _realPage.destroy()
112 _realPage = messagesComponent.createObject(null)
113 }
114
115
116=== modified file 'src/qml/MessagingPageLayout.qml'
117--- src/qml/MessagingPageLayout.qml 2016-02-05 21:19:56 +0000
118+++ src/qml/MessagingPageLayout.qml 2016-03-17 21:07:09 +0000
119@@ -5,6 +5,19 @@
120 id: layout
121 property var _pagesToRemove: []
122
123+ layouts: PageColumnsLayout {
124+ when: mainStack.width >= units.gu(90)
125+ PageColumn {
126+ maximumWidth: units.gu(50)
127+ minimumWidth: units.gu(40)
128+ preferredWidth: units.gu(40)
129+ }
130+ PageColumn {
131+ fillWidth: true
132+ }
133+ }
134+
135+
136 function deleteInstances() {
137 for (var i in _pagesToRemove) {
138 if (_pagesToRemove[i].destroy) {
139
140=== modified file 'src/qml/SettingsPage.qml'
141--- src/qml/SettingsPage.qml 2016-02-01 14:29:16 +0000
142+++ src/qml/SettingsPage.qml 2016-03-17 21:07:09 +0000
143@@ -30,6 +30,17 @@
144 }
145 ]
146
147+ // These fake items are used to track if there are instances loaded
148+ // on the second column because we have no access to the page stack
149+ Loader {
150+ sourceComponent: fakeItemComponent
151+ active: true
152+ }
153+ Component {
154+ id: fakeItemComponent
155+ Item { objectName:"fakeItem"}
156+ }
157+
158 GSettings {
159 id: gsettings
160 schema.id: "com.ubuntu.phone"
161@@ -38,6 +49,23 @@
162 header: PageHeader {
163 id: pageHeader
164 title: settingsPage.title
165+ leadingActionBar {
166+ actions: [
167+ Action {
168+ id: singlePanelBackAction
169+ objectName: "back"
170+ name: "cancel"
171+ text: i18n.tr("Cancel")
172+ iconName: "back"
173+ shortcut: "Esc"
174+ visible: !mainView.dualPanel
175+ onTriggered: {
176+ // emptyStack will make sure the page gets removed.
177+ mainView.emptyStack()
178+ }
179+ }
180+ ]
181+ }
182 }
183
184 Component {
185
186=== modified file 'src/qml/messaging-app.qml'
187--- src/qml/messaging-app.qml 2016-02-24 18:17:55 +0000
188+++ src/qml/messaging-app.qml 2016-03-17 21:07:09 +0000
189@@ -147,7 +147,7 @@
190 }
191
192 automaticOrientation: true
193- width: Screen.desktopAvailableWidth > units.gu(100) ? units.gu(100) : units.gu(40)
194+ width: units.gu(90)
195 height: units.gu(71)
196 anchorToKeyboard: false
197
198@@ -158,8 +158,6 @@
199 // when running in windowed mode, do not allow resizing
200 view.minimumWidth = units.gu(40)
201 view.minimumHeight = units.gu(60)
202-
203- emptyStack()
204 }
205
206 Connections {
207@@ -233,11 +231,12 @@
208 mainStack.removePage(mainPage)
209 layout.deleteInstances()
210 showEmptyState()
211+ mainPage.displayedThreadIndex = -1
212 }
213
214 function showEmptyState() {
215- if (mainStack.columns > 1) {
216- layout.addComponentToNextColumnSync(mainStack.primaryPage, emptyStatePageComponent)
217+ if (mainStack.columns > 1 && !application.findMessagingChild("emptyStatePage")) {
218+ layout.addComponentToNextColumnSync(mainPage, emptyStatePageComponent)
219 }
220 }
221
222@@ -341,6 +340,19 @@
223 id: emptyStatePageComponent
224 Page {
225 id: emptyStatePage
226+ objectName: "emptyStatePage"
227+ Connections {
228+ target: layout
229+ onColumnsChanged: {
230+ if (layout.columns == 1) {
231+ emptyStatePage.destroy(1)
232+ emptyStatePage.objectName = ""
233+ if (!application.findMessagingChild("fakeItem")) {
234+ layout.removePage(mainPage)
235+ }
236+ }
237+ }
238+ }
239
240 EmptyState {
241 labelVisible: false
242@@ -368,9 +380,14 @@
243
244 onColumnsChanged: {
245 // we only have things to do here in case no thread is selected
246- if (mainPage.displayedThreadIndex < 0) {
247+ if (layout.columns == 2 && !application.findMessagingChild("emptyStatePage") && !application.findMessagingChild("fakeItem")) {
248 layout.removePage(mainPage)
249- showEmptyState()
250+ emptyStack()
251+ }
252+ }
253+ Component.onCompleted: {
254+ if (layout.columns == 2 && !application.findMessagingChild("emptyStatePage")) {
255+ emptyStack()
256 }
257 }
258 }
259
260=== modified file 'tests/qml/tst_MessagesView.qml'
261--- tests/qml/tst_MessagesView.qml 2016-01-22 16:27:34 +0000
262+++ tests/qml/tst_MessagesView.qml 2016-03-17 21:07:09 +0000
263@@ -71,6 +71,14 @@
264 }
265 }
266
267+ Item {
268+ id: application
269+ function findMessagingChild(name)
270+ {
271+ return null
272+ }
273+ }
274+
275 QtObject {
276 id: testAccount
277 property string accountId: "ofono/ofono/account0"
278@@ -119,6 +127,27 @@
279
280 when: windowShown
281
282+ // we reimplement the function here and add a special
283+ // case to deal with a null child without failing
284+ function findChild(obj,objectName) {
285+ var childs = new Array(0);
286+ childs.push(obj)
287+ while (childs.length > 0) {
288+ // this is the special case
289+ if (!childs[0]) {
290+ childs.splice(0, 1);
291+ }
292+ if (childs[0].objectName == objectName) {
293+ return childs[0]
294+ }
295+ for (var i in childs[0].children) {
296+ childs.push(childs[0].children[i])
297+ }
298+ childs.splice(0, 1);
299+ }
300+ return null;
301+ }
302+
303 function init() {
304 }
305

Subscribers

People subscribed via source and target branches