aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
authorjoe berner <stackyjoe@gmail.com>2018-12-18 11:21:59 -0600
committerjoe berner <stackyjoe@gmail.com>2018-12-18 11:21:59 -0600
commita25b2294f58be2cc1f53e759155d9f7c2d53efde (patch)
tree925c9bfa8d188f55b82a87f8fca1ebe882b22e21 /src-qt5/desktop-utils
parentChanges the UI interface so that only the current page is rendered on screen ... (diff)
downloadlumina-a25b2294f58be2cc1f53e759155d9f7c2d53efde.tar.gz
lumina-a25b2294f58be2cc1f53e759155d9f7c2d53efde.tar.bz2
lumina-a25b2294f58be2cc1f53e759155d9f7c2d53efde.zip
Switches from keeping links in a QHash to a std::vector. This fixes some race conditions on key insertion from multiple threads.
Diffstat (limited to 'src-qt5/desktop-utils')
-rwxr-xr-xsrc-qt5/desktop-utils/build-lumina-pdf-Desktop-Debug/lumina-pdfbin0 -> 9565048 bytes
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp20
2 files changed, 9 insertions, 11 deletions
diff --git a/src-qt5/desktop-utils/build-lumina-pdf-Desktop-Debug/lumina-pdf b/src-qt5/desktop-utils/build-lumina-pdf-Desktop-Debug/lumina-pdf
new file mode 100755
index 00000000..a63b6a41
--- /dev/null
+++ b/src-qt5/desktop-utils/build-lumina-pdf-Desktop-Debug/lumina-pdf
Binary files differ
diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
index d90f36d3..6e5ff382 100644
--- a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
@@ -12,7 +12,7 @@ QHash<int, QImage> loadingHash;
static std::vector<LuminaPDF::drawablePage> pages;
static std::vector<QList<LuminaPDF::Link *>> links;
static std::atomic<int> pagesStillLoading;
-static QHash<int, QList<LuminaPDF::Link *>> linkHash;
+// static QHash<int, QList<LuminaPDF::Link *>> linkHash;
static LuminaPDF::LRUCache<QImage> imageCache;
Renderer::Renderer() : pnum(0), needpass(false), degrees(0) {
@@ -42,12 +42,7 @@ bool Renderer::loadDocument(QString path, QString password) {
// Clear out the old document first
DOC.reset(nullptr);
pages.clear();
- if (linkHash.size() > 0) {
- foreach (QList<LuminaPDF::Link *> linkArray, linkHash) {
- qDeleteAll(linkArray);
- }
- linkHash.clear();
- }
+ links.clear();
needpass = false;
pnum = 0;
docpath = path;
@@ -213,7 +208,10 @@ void Renderer::traverseOutline(void *, int) {}
void Renderer::handleLink(QWidget *obj, QString linkDest) {
Poppler::Link *trueLink;
- foreach (QList<LuminaPDF::Link *> linkArray, linkHash) {
+ for (std::vector<QList<LuminaPDF::Link *>>::iterator link_itr = links.begin();
+ link_itr != links.end(); ++link_itr) {
+ auto linkArray = *link_itr;
+
for (int i = 0; i < linkArray.size(); i++) {
Poppler::Link *link = linkArray[i]->getLink();
if (link->linkType() == Poppler::Link::LinkType::Browse) {
@@ -245,14 +243,14 @@ void Renderer::handleLink(QWidget *obj, QString linkDest) {
}
TextData *Renderer::linkList(int pageNum, int entry) {
- if (linkHash[pageNum].size() > 0)
- return linkHash[pageNum][entry]->getData();
+ if (links[pageNum].size() > 0)
+ return links[pageNum][entry]->getData();
else
return 0;
}
int Renderer::linkSize(int pageNum) {
- Q_UNUSED(pageNum) return linkHash[pageNum].size();
+ Q_UNUSED(pageNum) return links[pageNum].size();
}
int Renderer::annotSize(int pageNum) { Q_UNUSED(pageNum) return 0; }
bgstack15