← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Michael Zanetti has proposed merging lp:~mzanetti/reminders-app/cleanup-pages into lp:reminders-app.

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

Requested reviews:
  Ubuntu Reminders app developers (reminders-app-dev)
Related bugs:
  Bug #1452639 in Ubuntu Notes app: "text loss in reminders on screen rotation "
  https://bugs.launchpad.net/reminders-app/+bug/1452639

For more details, see:
https://code.launchpad.net/~mzanetti/reminders-app/cleanup-pages/+merge/260395
-- 
Your team Ubuntu Reminders app developers is requested to review the proposed merge of lp:~mzanetti/reminders-app/cleanup-pages into lp:reminders-app.
=== modified file 'src/app/qml/reminders.qml'
--- src/app/qml/reminders.qml	2015-04-13 21:32:13 +0000
+++ src/app/qml/reminders.qml	2015-05-27 22:47:24 +0000
@@ -96,17 +96,10 @@
 
     backgroundColor: "#dddddd"
 
-    property var accountPage;
-
-    function openAccountPage(isChangingAccount) {
+    function openAccountPage() {
         var unauthorizedAccounts = allAccounts.count - accounts.count > 0 ? true : false
-        if (accountPage) {
-            accountPage.destroy(100)
-        }
-        var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));
-        accountPage = component.createObject(root, { accounts: accounts, unauthorizedAccounts: unauthorizedAccounts, oaSetup: setup });
+        var accountPage = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml")), { accounts: accounts, unauthorizedAccounts: unauthorizedAccounts, oaSetup: setup });
         accountPage.accountSelected.connect(function(username, handle) { accountService.startAuthentication(username, handle); pagestack.pop(); root.accountPage = null });
-        pagestack.push(accountPage);
     }
 
     function displayNote(note, conflictMode) {
@@ -118,11 +111,9 @@
         note.load(true);
         if (root.narrowMode) {
             print("creating noteview");
-            var page;
             if (!conflictMode && note.conflicting) {
                 // User wants to open the note even though it is conflicting! Show the Conflict page instead.
-                var component = Qt.createComponent(Qt.resolvedUrl("ui/NoteConflictPage.qml"));
-                page = component.createObject(root, {note: note});
+                var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NoteConflictPage.qml")), {note: note});
                 page.displayNote.connect(function(note) { root.displayNote(note, true); } );
                 page.resolveConflict.connect(function(keepLocal) {
                     var confirmation = PopupUtils.open(Qt.resolvedUrl("components/ResolveConflictConfirmationDialog.qml"), page, {keepLocal: keepLocal, remoteDeleted: note.conflictingNote.deleted, localDeleted: note.deleted});
@@ -132,12 +123,10 @@
                     });
                 })
             } else {
-                var component = Qt.createComponent(Qt.resolvedUrl("ui/NotePage.qml"));
-                page = component.createObject(root, {readOnly: conflictMode, note: note });
+                var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotePage.qml")), {readOnly: conflictMode, note: note })
                 page.editNote.connect(function(note) {root.switchToEditMode(note)})
                 page.openTaggedNotes.connect(function(title, tagGuid) {pagestack.pop();root.openTaggedNotes(title, tagGuid, true)})
             }
-            pagestack.push(page)
         } else {
             var view;
             if (!conflictMode && note.conflicting) {
@@ -166,10 +155,8 @@
             if (pagestack.depth > 1) {
                 pagestack.pop();
             }
-            var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
-            var page = component.createObject();
+            var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note});
             page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop()});
-            pagestack.push(page, {note: note});
         } else {
             sideViewLoader.clear();
             var view = sideViewLoader.embed(Qt.resolvedUrl("ui/EditNoteView.qml"))
@@ -180,9 +167,7 @@
     }
 
     function openSearch() {
-        var component = Qt.createComponent(Qt.resolvedUrl("ui/SearchNotesPage.qml"))
-        var page = component.createObject();
-        pagestack.push(page)
+        var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/SearchNotesPage.qml")))
         page.noteSelected.connect(function(note) {root.displayNote(note)})
         page.editNote.connect(function(note) {root.switchToEditMode(note)})
     }
@@ -217,7 +202,7 @@
             break;
         default:
             print("There are multiple accounts. Allowing user to select one.");
-            openAccountPage(false);
+            openAccountPage();
         }
     }
 
@@ -317,10 +302,8 @@
     }
 
     function openTaggedNotes(title, tagGuid, narrowMode) {
-        var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
-        var page = component.createObject();
         print("opening note page for tag", tagGuid)
-        pagestack.push(page, {title: title, filterTagGuid: tagGuid, narrowMode: narrowMode});
+        var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: title, filterTagGuid: tagGuid, narrowMode: narrowMode});
         page.selectedNoteChanged.connect(function() {
             if (page.selectedNote) {
                 root.displayNote(page.selectedNote);
@@ -441,10 +424,8 @@
             var note = NotesStore.note(guid);
             print("note created:", note.guid);
             if (root.narrowMode) {
-                var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
-                var page = component.createObject();
+                var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note});
                 page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop();});
-                pagestack.push(page, {note: note});
             } else {
                 notesPage.selectedNote = note;
                 var view = sideViewLoader.embed(Qt.resolvedUrl("ui/EditNoteView.qml"));
@@ -526,10 +507,8 @@
                     onOpenNotebook: {
                         var notebook = NotesStore.notebook(notebookGuid)
                         print("have notebook:", notebook, notebook.name)
-                        var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
-                        var page = component.createObject();
                         print("opening note page for notebook", notebookGuid)
-                        pagestack.push(page, {title: notebook.name, filterNotebookGuid: notebookGuid, narrowMode: root.narrowMode});
+                        var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: notebook.name, filterNotebookGuid: notebookGuid, narrowMode: root.narrowMode});
                         page.selectedNoteChanged.connect(function() {
                             if (page.selectedNote) {
                                 root.displayNote(page.selectedNote);
@@ -575,10 +554,8 @@
 
                     onOpenTaggedNotes: {
                         var tag = NotesStore.tag(tagGuid);
-                        var component = Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml"))
-                        var page = component.createObject();
                         print("opening note page for tag", tagGuid)
-                        pagestack.push(page, {title: tag.name, filterTagGuid: tagGuid, narrowMode: root.narrowMode});
+                        var page = pagestack.push(Qt.createComponent(Qt.resolvedUrl("ui/NotesPage.qml")), {title: tag.name, filterTagGuid: tagGuid, narrowMode: root.narrowMode});
                         page.selectedNoteChanged.connect(function() {
                             if (page.selectedNote) {
                                 root.displayNote(page.selectedNote);

=== modified file 'src/app/qml/ui/AccountSelectorPage.qml'
--- src/app/qml/ui/AccountSelectorPage.qml	2015-03-03 20:02:06 +0000
+++ src/app/qml/ui/AccountSelectorPage.qml	2015-05-27 22:47:24 +0000
@@ -75,7 +75,7 @@
                 }
 
                 Component.onCompleted: {
-                    if (isChangingAccount && displayName == preferences.accountName) {
+                    if (displayName == preferences.accountName) {
                         optionSelector.selectedIndex = index;
                     }
                     if (!model.enabled) {

=== modified file 'src/app/qml/ui/EditNoteView.qml'
--- src/app/qml/ui/EditNoteView.qml	2015-05-07 21:41:41 +0000
+++ src/app/qml/ui/EditNoteView.qml	2015-05-27 22:47:24 +0000
@@ -84,8 +84,10 @@
     Connections {
         target: noteTextArea
         onWidthChanged: {
-            note.richTextContent = noteTextArea.text;
-            note.renderWidth = noteTextArea.width - noteTextArea.textMargin * 2
+            if (note) {
+                note.richTextContent = noteTextArea.text;
+                note.renderWidth = noteTextArea.width - noteTextArea.textMargin * 2
+            }
         }
     }
 

=== modified file 'src/app/qml/ui/NotePage.qml'
--- src/app/qml/ui/NotePage.qml	2015-03-15 20:00:21 +0000
+++ src/app/qml/ui/NotePage.qml	2015-05-27 22:47:24 +0000
@@ -63,7 +63,6 @@
         anchors.fill: parent
 
         onOpenTaggedNotes: {
-            console.log('babbo natale')
             root.openTaggedNotes(title, tagGuid);
         }
     }


Follow ups