Merge lp:~mzanetti/reminders-app/cleanup-pages into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 442
Merged at revision: 444
Proposed branch: lp:~mzanetti/reminders-app/cleanup-pages
Merge into: lp:reminders-app
Diff against target: 172 lines (+16/-38)
4 files modified
src/app/qml/reminders.qml (+11/-34)
src/app/qml/ui/AccountSelectorPage.qml (+1/-1)
src/app/qml/ui/EditNoteView.qml (+4/-2)
src/app/qml/ui/NotePage.qml (+0/-1)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/cleanup-pages
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+260395@code.launchpad.net

Commit message

don't create pages manually as the pageStack won't delete them

This caused us to leak all the pages and cause weird issues in the editnoteview

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Makes sense, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/reminders.qml'
2--- src/app/qml/reminders.qml 2015-04-13 21:32:13 +0000
3+++ src/app/qml/reminders.qml 2015-05-27 22:47:24 +0000
4@@ -96,17 +96,10 @@
5
6 backgroundColor: "#dddddd"
7
8- property var accountPage;
9-
10- function openAccountPage(isChangingAccount) {
11+ function openAccountPage() {
12 var unauthorizedAccounts = allAccounts.count - accounts.count > 0 ? true : false
13- if (accountPage) {
14- accountPage.destroy(100)
15- }
16- var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));
17- accountPage = component.createObject(root, { accounts: accounts, unauthorizedAccounts: unauthorizedAccounts, oaSetup: setup });
18+ var accountPage = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml")), { accounts: accounts, unauthorizedAccounts: unauthorizedAccounts, oaSetup: setup });
19 accountPage.accountSelected.connect(function(username, handle) { accountService.startAuthentication(username, handle); pagestack.pop(); root.accountPage = null });
20- pagestack.push(accountPage);
21 }
22
23 function displayNote(note, conflictMode) {
24@@ -118,11 +111,9 @@
25 note.load(true);
26 if (root.narrowMode) {
27 print("creating noteview");
28- var page;
29 if (!conflictMode && note.conflicting) {
30 // User wants to open the note even though it is conflicting! Show the Conflict page instead.
31- var component = Qt.createComponent(Qt.resolvedUrl("ui/NoteConflictPage.qml"));
32- page = component.createObject(root, {note: note});
33+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NoteConflictPage.qml")), {note: note});
34 page.displayNote.connect(function(note) { root.displayNote(note, true); } );
35 page.resolveConflict.connect(function(keepLocal) {
36 var confirmation = PopupUtils.open(Qt.resolvedUrl("components/ResolveConflictConfirmationDialog.qml"), page, {keepLocal: keepLocal, remoteDeleted: note.conflictingNote.deleted, localDeleted: note.deleted});
37@@ -132,12 +123,10 @@
38 });
39 })
40 } else {
41- var component = Qt.createComponent(Qt.resolvedUrl("ui/NotePage.qml"));
42- page = component.createObject(root, {readOnly: conflictMode, note: note });
43+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotePage.qml")), {readOnly: conflictMode, note: note })
44 page.editNote.connect(function(note) {root.switchToEditMode(note)})
45 page.openTaggedNotes.connect(function(title, tagGuid) {pagestack.pop();root.openTaggedNotes(title, tagGuid, true)})
46 }
47- pagestack.push(page)
48 } else {
49 var view;
50 if (!conflictMode && note.conflicting) {
51@@ -166,10 +155,8 @@
52 if (pagestack.depth > 1) {
53 pagestack.pop();
54 }
55- var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
56- var page = component.createObject();
57+ var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note});
58 page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop()});
59- pagestack.push(page, {note: note});
60 } else {
61 sideViewLoader.clear();
62 var view = sideViewLoader.embed(Qt.resolvedUrl("ui/EditNoteView.qml"))
63@@ -180,9 +167,7 @@
64 }
65
66 function openSearch() {
67- var component = Qt.createComponent(Qt.resolvedUrl("ui/SearchNotesPage.qml"))
68- var page = component.createObject();
69- pagestack.push(page)
70+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/SearchNotesPage.qml")))
71 page.noteSelected.connect(function(note) {root.displayNote(note)})
72 page.editNote.connect(function(note) {root.switchToEditMode(note)})
73 }
74@@ -217,7 +202,7 @@
75 break;
76 default:
77 print("There are multiple accounts. Allowing user to select one.");
78- openAccountPage(false);
79+ openAccountPage();
80 }
81 }
82
83@@ -317,10 +302,8 @@
84 }
85
86 function openTaggedNotes(title, tagGuid, narrowMode) {
87- var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
88- var page = component.createObject();
89 print("opening note page for tag", tagGuid)
90- pagestack.push(page, {title: title, filterTagGuid: tagGuid, narrowMode: narrowMode});
91+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: title, filterTagGuid: tagGuid, narrowMode: narrowMode});
92 page.selectedNoteChanged.connect(function() {
93 if (page.selectedNote) {
94 root.displayNote(page.selectedNote);
95@@ -441,10 +424,8 @@
96 var note = NotesStore.note(guid);
97 print("note created:", note.guid);
98 if (root.narrowMode) {
99- var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
100- var page = component.createObject();
101+ var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note});
102 page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop();});
103- pagestack.push(page, {note: note});
104 } else {
105 notesPage.selectedNote = note;
106 var view = sideViewLoader.embed(Qt.resolvedUrl("ui/EditNoteView.qml"));
107@@ -526,10 +507,8 @@
108 onOpenNotebook: {
109 var notebook = NotesStore.notebook(notebookGuid)
110 print("have notebook:", notebook, notebook.name)
111- var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
112- var page = component.createObject();
113 print("opening note page for notebook", notebookGuid)
114- pagestack.push(page, {title: notebook.name, filterNotebookGuid: notebookGuid, narrowMode: root.narrowMode});
115+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: notebook.name, filterNotebookGuid: notebookGuid, narrowMode: root.narrowMode});
116 page.selectedNoteChanged.connect(function() {
117 if (page.selectedNote) {
118 root.displayNote(page.selectedNote);
119@@ -575,10 +554,8 @@
120
121 onOpenTaggedNotes: {
122 var tag = NotesStore.tag(tagGuid);
123- var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
124- var page = component.createObject();
125 print("opening note page for tag", tagGuid)
126- pagestack.push(page, {title: tag.name, filterTagGuid: tagGuid, narrowMode: root.narrowMode});
127+ var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: tag.name, filterTagGuid: tagGuid, narrowMode: root.narrowMode});
128 page.selectedNoteChanged.connect(function() {
129 if (page.selectedNote) {
130 root.displayNote(page.selectedNote);
131
132=== modified file 'src/app/qml/ui/AccountSelectorPage.qml'
133--- src/app/qml/ui/AccountSelectorPage.qml 2015-03-03 20:02:06 +0000
134+++ src/app/qml/ui/AccountSelectorPage.qml 2015-05-27 22:47:24 +0000
135@@ -75,7 +75,7 @@
136 }
137
138 Component.onCompleted: {
139- if (isChangingAccount && displayName == preferences.accountName) {
140+ if (displayName == preferences.accountName) {
141 optionSelector.selectedIndex = index;
142 }
143 if (!model.enabled) {
144
145=== modified file 'src/app/qml/ui/EditNoteView.qml'
146--- src/app/qml/ui/EditNoteView.qml 2015-05-07 21:41:41 +0000
147+++ src/app/qml/ui/EditNoteView.qml 2015-05-27 22:47:24 +0000
148@@ -84,8 +84,10 @@
149 Connections {
150 target: noteTextArea
151 onWidthChanged: {
152- note.richTextContent = noteTextArea.text;
153- note.renderWidth = noteTextArea.width - noteTextArea.textMargin * 2
154+ if (note) {
155+ note.richTextContent = noteTextArea.text;
156+ note.renderWidth = noteTextArea.width - noteTextArea.textMargin * 2
157+ }
158 }
159 }
160
161
162=== modified file 'src/app/qml/ui/NotePage.qml'
163--- src/app/qml/ui/NotePage.qml 2015-03-15 20:00:21 +0000
164+++ src/app/qml/ui/NotePage.qml 2015-05-27 22:47:24 +0000
165@@ -63,7 +63,6 @@
166 anchors.fill: parent
167
168 onOpenTaggedNotes: {
169- console.log('babbo natale')
170 root.openTaggedNotes(title, tagGuid);
171 }
172 }

Subscribers

People subscribed via source and target branches