Re: NSPDFImageRep vs. NSProgressIndicator
Re: NSPDFImageRep vs. NSProgressIndicator
- Subject: Re: NSPDFImageRep vs. NSProgressIndicator
- From: Robert Cerny <email@hidden>
- Date: Mon, 2 Dec 2002 12:33:20 +0100
Hi,
because nobody sent you an answer, I will try to help you. This problem
was discussed here for many times. The problem isn't in pdf machinery
at all. The problem is that animating of your spinner is in the same
thread as the pdf job, so working with pdf stops spinning. The
solutions are two:
1. if you're on 10.2, there is a new method (I can't recall its name
now)
2. Use DO or any other approach to move loadPDF method to a different
thread.
HTH
Robert
On Saturday, November 30, 2002, at 09:41 PM, m wrote:
Hi, I'm a newbie to Cocoa.
I've got a multipage pdf that I'm displaying in window using an
NSImageView (using an NSPDFImageRep instance). When I load the pdf,
there a delay before the pdf is displayed that is long enough to make
you think something's amiss, but not long enough for the busy cursor
to come up. A suboptimal user experience I'd like to avoid.
So I thought I'd put a NSProgressIndicator in the window to which I'd
send a startAnimating message just before displaying the pdf and a
stopAnimating message afterwards. But it seems that there is something
within the pdf rendering machinery that stops progress indicators
cold. To prove this to myself, I wrote a small test app that starts
the progress indicator spinning in a controller object's awakeFromNib
method. Then I load the pdf.
To wit:
- (void)awakeFromNib
{
[_spinner setUsesThreadedAnimation:YES];
[_spinner startAnimation:self];
}
- (IBAction)loadPDF:(id)sender
{
// attempt to load a new pdf
NSImage* pdfImage = [[NSImage alloc]
initByReferencingFile:@"some.pdf"];
if (pdfImage && [pdfImage isValid])
{
[pdfImage retain];
[_imageView setImage: pdfImage];
[_imageView display]; // <- spinner stops spinning here
}
}
The progress indicator grinds to a halt for the duration of the
[_imageView display] call. Seems wrong to me.
The thing is, no matter what I do, the NSProgressIndicator stops
animating while the pdf is being imaged.
As you can see from my awakefromNib method, I have tried the [_spinner
setUsesThreadedAnimation:YES] trick, and it doesn't work.
I had a feeling that this could be due to the NSView locking focus for
the duration of the display method. So I tried putting a second
progress indicator in a second window by itself. Same thing, ergo, I
don't think its a locked focus thing (I could be talked out of it
though).
Any explanations or tips on how to get around this?
cheers,
_murat
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.