← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering-thread-optimization into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering

 

Roman Shchekin has proposed merging lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering-thread-optimization into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering.

Commit message:
Page loading optimization.

Requested reviews:
  Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)

For more details, see:
https://code.launchpad.net/~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering-thread-optimization/+merge/263854

Page loading optimization.
-- 
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering-thread-optimization into lp:~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-tiled-rendering.
=== modified file 'src/plugin/poppler-qml-plugin/pdfdocument.cpp'
--- src/plugin/poppler-qml-plugin/pdfdocument.cpp	2015-03-25 16:51:53 +0000
+++ src/plugin/poppler-qml-plugin/pdfdocument.cpp	2015-07-05 22:27:28 +0000
@@ -27,6 +27,8 @@
 #include <QQmlContext>
 #include <QThread>
 
+#include <QtConcurrent/QtConcurrent>
+
 PdfDocument::PdfDocument(QAbstractListModel *parent):
     QAbstractListModel(parent)
   , m_path("")
@@ -145,12 +147,15 @@
     if (!m_document)
         return false;
 
-    PdfThread *pdfThread = new PdfThread();
-    pdfThread->setDocument(m_document);
-
-    connect(pdfThread, SIGNAL(resultReady(PdfPagesList)), this, SLOT(_q_populate(PdfPagesList)));
-    connect(pdfThread, SIGNAL(finished()), pdfThread, SLOT(deleteLater()));
-    pdfThread->start();
+    Poppler::Document* document = m_document;
+    QtConcurrent::run( [=] {
+        PdfPagesList pages;
+
+        for( int i = 0; i < document->numPages(); ++i )
+            pages.append(document->page(i));
+
+        QMetaObject::invokeMethod(this, "_q_populate", Qt::QueuedConnection, Q_ARG(PdfPagesList, pages));
+    });
 
     return true;
 }