Skip Menu |

This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics
Id: 81530
Status: rejected
Priority: 0/
Queue: PDF-API2

People
Owner: Nobody in particular
Requestors: linux [...] eikelenboom.it
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH} PDF::API2 don't destroy pdf object on stringify or save and saves but leave it to the user
Date: Thu, 29 Nov 2012 11:47:40 +0100
To: bug-PDF-API2 [...] rt.cpan.org
From: Sander Eikelenboom <linux [...] eikelenboom.it>
Hi, At the moment the following is not working: $pdf = PDF::API2->new(); ... my $filename = md5($pdf->stringify() . "pdf"); $pdf->saveas($filename); $pdf->end(); This is because stringify (and save and saveas) destroy the object. I think it would be better to leave this to the user and let him invoke $pdf->end(); Patch is attached. -- Sander

Message body is not shown because sender requested not to inline it.

Thank you for taking the time to write up a patch and send it in! Show quoted text
> I think it would be better to leave this to the user and let him > invoke $pdf->end();
If we were starting from scratch, I'd agree with you. However, if I were to implement this now, it would break quite a lot of existing code by not freeing up the memory that people are expecting to be freed (or at least accustomed to being freed). See the comment in PDF::API2::Basic::PDF::File's "release" method to see why this is important. However, I've made a note to clarify the documentation to the stringify method to say that it's destructive (I've been bit by this gotcha as well), and will consider other ways to implement something similar.