← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1444972 into lp:ubuntu-docviewer-app

 

Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1444972 into lp:ubuntu-docviewer-app.

Commit message:
[PDF] Fixed docviewer crash when selecting the last entry of the ToC

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
Related bugs:
  Bug #1444972 in Ubuntu Document Viewer App: "docviewer crashes on going at the last item of the ToC"
  https://bugs.launchpad.net/ubuntu-docviewer-app/+bug/1444972

For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/fix-1444972/+merge/256486

[PDF] Fixed docviewer crash when selecting the last entry of the ToC
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/fix-1444972 into lp:ubuntu-docviewer-app.
=== modified file 'po/com.ubuntu.docviewer.pot'
--- po/com.ubuntu.docviewer.pot	2015-04-13 15:56:00 +0000
+++ po/com.ubuntu.docviewer.pot	2015-04-16 13:02:18 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-04-13 17:55+0200\n"
+"POT-Creation-Date: 2015-04-16 14:55+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -215,7 +215,7 @@
 msgstr ""
 
 #: ../src/app/qml/documentPage/DocumentPage.qml:25
-#: /home/stefano/Progetti/doc-viewer/build-adv-import-handler-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:1
 msgid "Document Viewer"
 msgstr ""
 
@@ -304,6 +304,6 @@
 msgid "Open"
 msgstr ""
 
-#: /home/stefano/Progetti/doc-viewer/build-adv-import-handler-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
+#: /home/stefano/Progetti/doc-viewer/build-ubuntu-docviewer-app-Desktop-Default/po/com.ubuntu.docviewer.desktop.in.in.h:2
 msgid "documents;viewer;pdf;reader;"
 msgstr ""

=== modified file 'src/app/qml/pdfView/PdfContentsPage.qml'
--- src/app/qml/pdfView/PdfContentsPage.qml	2015-04-10 15:48:58 +0000
+++ src/app/qml/pdfView/PdfContentsPage.qml	2015-04-16 13:02:18 +0000
@@ -39,10 +39,13 @@
         mainView.setHeaderVisibility(true);
 
         // Find out the current page position in the ToC index
-        var i=0
-        while(!(pdfView.currentPageIndex >= poppler.tocModel.get(i).pageIndex &&
-              pdfView.currentPageIndex < poppler.tocModel.get(i+1).pageIndex)) {
-            i++
+        for (var i=0; i<poppler.tocModel.count; i++) {
+            if (i+1 < poppler.tocModel.count) {
+                if (pdfView.currentPageIndex >= poppler.tocModel.get(i).pageIndex &&
+                        pdfView.currentPageIndex < poppler.tocModel.get(i+1).pageIndex) {
+                    break;
+                }
+            }
         }
 
         // Set highlighted index

=== modified file 'src/plugin/poppler-qml-plugin/pdftocmodel.cpp'
--- src/plugin/poppler-qml-plugin/pdftocmodel.cpp	2015-04-08 14:11:02 +0000
+++ src/plugin/poppler-qml-plugin/pdftocmodel.cpp	2015-04-16 13:02:18 +0000
@@ -74,7 +74,7 @@
 
 QVariantMap PdfTocModel::get(int index) const
 {
-    if (index < 0 && index > m_entries.length()) {
+    if (index < 0 || index > m_entries.length() - 1) {
         qWarning() << Q_FUNC_INFO << "Index not valid, return undefined";
         return QVariantMap();
     }


Follow ups