Re: PDFView setDocument: autorelease crash?
Re: PDFView setDocument: autorelease crash?
- Subject: Re: PDFView setDocument: autorelease crash?
- From: John Calhoun <email@hidden>
- Date: Mon, 12 Mar 2007 12:30:32 -0700
On Mar 10, 2007, at 6:52 AM, Keith Blount wrote:
// NOTE: to reset the PDFView properly, we have to go to the first
page before setting the document to nil. If we don't
// do this, we get weird results when trying to go to a page
after loading a new document. Weird, but it works...
[pdfView goToFirstPage:nil];
[pdfView setDocument:nil];
That's a little strange. -[setDocument] and -[goToFirstPage] both
reset the page index to zero and reset the view layout. If anything -
[goToFirstPage] is something of a redundant subset of -[setDocument].
What weird behavior are you seeing?
As far as I can see, all of this should work. However, users have
been reporting various autorelease-type crashes related to PDF
files, and today I finally managed to track the crash. It turns out
that calling -setDocument over-releases the PDF document, for some
reason. If I change my -loadPDFDocumentFromFile: method so that the
PDFDocument does not get autoreleased, everything works fine with no
crashes, as follows:
-[setDocument (on Tiger) autoreleases the current document and then
retains the document passed in. I wonder if your extra retain is
instead masking a bug/crash somewhere else.
In fact a bug has been found in Tiger that showed itself when re-using
a single PDFView for different documents. It was related to PDFView's
handling of tooltips (for Link annotations for example). The
workaround was to either create a new PDFView for each PDFDocument or
to instead turn off tooltips handling (PDFView subclass, implement -
(void) [scheduleAddingToolips] and do nothing in this method).
That's the best my hazy recollection can offer up.
Is this a bug in PDFView, or have I missed something obvious?
A bug but as I say, I think elsewhere. Have you tried the code on
Leopard? I believe these issues are fixed without requiring the
workarounds. Before Leopard ships it would be nice to know if there
is more work to do. :-)
john calhoun—
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden