Closed matias-pizarro closed 5 years ago
There is no LuminaPDF::LRUCache::contains() There is LuminaPDF::LRUCache::get()
good catch!
I can confirm this bug.
Fixing it isn't too bad,
bool contains(const Key key) { return hashmap.find(key) != hashmap.end();}
Is the implementation I meant.
However even with that the build doesn't result in a functional pdf. At least when compiled with Poppler it doesn't actually display the loaded file. I'm looking at the diffs between the last version I had working at the current one but I haven't figured out the exact change yet. I know the code I wrote up wasn't too easy to square with the muPDF option.
The issue is that the function Renderer::isDoneLoading() was changed from reporting on an atomic int pagesStillLoading to being a function of an integer that tells if a page is done loading. To make it work for both Poppler and muPDF it was changed to
Renderer::isDoneLoading(int page) { return imageCache.contains(page); }
Which isn't what you want. The object imageCache is an LRUCache of the QImages, we should be looking at the pages object instead. However changing that doesn't seem to work, since the isDoneLoading() can actually be called before pages
is filled with dummy drawablePage objects, leading to dereferencing a null pointer.
After reading more about Qt5, I think the easiest way to get it working again is to revert to before the PR I submitted, and change the PageItem class in printwidget.h to not own a QImage object, but instead own a small wrapper around the mupdf/poppler page. This wrapper only needs to be able to create the image when requested in the PageItem::paint() function.
As far as I can tell from the documentation, QGraphicsScene already only paints visible items to its viewport. So this simple change would fix the memory issues. The PageItem::paint() function could also easily be linked to a LRUCache to improve responsiveness. There would still be some multi-threading issues, but I think that could be fixed separately without anything too difficult.
I'll play around with it in the next couple of days, and report back.
This is already fixed. The lumina-pdf utility has also been split out into it's own repository to make it easier to update on it's own as needed: https://github.com/lumina-desktop/lumina-pdf
Hello,
I'd appreciate any help I can get with the build error below. Let me know if you require any additional information.