Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Fix issue #4290 (--copies not working with --collate). #4301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vevisystems
Copy link

Per object QWebPrinter should be deleted after processing all copies.

Per object QWebPrinter should be deleted after processing all copies.
@@ -963,9 +963,6 @@ void PdfConverterPrivate::endPrintObject(PageObject & obj) {
pageFormElements.clear();

if (obj.web_printer != 0) {
delete obj.web_printer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, what happens in the call from line 887? I don't want to cause one more breakage due to a code path not being considered.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand the code (I have looked at it for just a few hours so I might be wrong) the loop at printDocument() deletes the web_printer after each object is used. The call from 887 (at beginPrintObject) deletes the web_printer of previous object when the loop advances, and finally the call from line 1012 clears the web_printer of the last object.

The problem is that when the "copies" loop (at 995) advances to print the next page, web_printers were already deleted so the next copy has nothing to print, and thus --copies always produces a single copy.

My solutions was to defer the web_printer deletion until all pages were processed, but of course it might be not the best solution (I might even be completely wrong!).

Be free to reject the PR if you have doubts about its correctness, as I said I have only looked at the code for a few hours. In any case, we have this solution working on a system that produces more than 50.000 PDFs per day (could not wait for official release because of the importance of the --copies feature to us), and it is working ok so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good to know. I'll review it in more detail this weekend and merge it 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the delay, I've been a bit busy but I'll look at it this week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants