IKImageView hangs?
IKImageView hangs?
- Subject: IKImageView hangs?
- From: Brian Postow <email@hidden>
- Date: Wed, 28 Jul 2010 16:17:01 -0400
I'm writing a scanning application that is getting images from a document scanner, turning them into NSImages and then displaying them in an IKImageView. About half of the time, however, when I try to call setImage:ImageProperties in IKImageView, it just hangs.
It only happens when I'm getting the image directly from the scanner, as I'm scanning. if I've gotten pages from the scanner, but not displayed them, but then after I step scanning, page up and down through pages, it works fine and never hangs (as far as I've seen).
The NSImage that gets scanned gets turned into a PDFPage and then inserted into a PDFDocument. Then, when I want to display a page, I get the image from the Page and display it. (Yes, I take an NSImage, turn it into a PDF, and then turn it back into an NSImage...)
Here is some code:
This is in my IKImageView subclass ( that also replaces isFlipped, and sets animates to NO)
-(void) setNSImage:(NSImage*) nsImage
{
CGImageRef cgImage = nsImageToCGImage(nsImage);
[self setImage:cgImage imageProperties:NULL];
}
CGImageRef nsImageToCGImage(NSImage* image)
{
NSData * imgData = [image TIFFRepresentation];
CGImageRef imgRef = 0;
if(imgData)
{
CGImageSourceRef imageSource =
CGImageSourceCreateWithData((CFDataRef)imgData, NULL);
imgRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
}
return imgRef;
}
To get the NSImage from the PDFDocument:
-(NSImage*) currentImage
{
return [[NSImage alloc] initWithData: [[doc pageAtIndex: pageNum] dataRepresentation]];
}
Here's the call stack where I hang:
#0 0x94a3a066 in __semwait_signal
#1 0x94a39d22 in _pthread_cond_wait
#2 0x94a3b9b8 in pthread_cond_wait$UNIX2003
#3 0x95238477 in -[NSViewHierarchyLock _lockForWriting:handler:]
#4 0x9523824d in -[NSViewHierarchyLock lockForWritingWithExceptionHandler:]
#5 0x9527d871 in -[NSView setBoundsOrigin:]
#6 0x9527d68c in -[NSClipView setBoundsOrigin:]
#7 0x93721e03 in -[IKImageLayer autoResizeToRect:allowZoomIn:]
#8 0x9371f228 in -[IKImageLayer _updateLayer:]
#9 0x93723098 in -[IKImageLayer doSetImage:imageProperties:imageState:options:]
#10 0x9371f5c1 in -[IKImageLayer setImage:imageProperties:imageState:options:]
#11 0x93731d35 in -[IKComposer setImage:imageProperties:imageState:options:]
#12 0x9372ace1 in -[IKImageView(IKPrivate) setImage:imageProperties:imageState:options:]
#13 0x9372c421 in -[IKImageView setImage:imageProperties:]
#14 0x00005bb4 in -[FlippedIKImageView setNSImage:] at FlippedIKImageView.m:84
thanks!
Brian Postow
Senior Software Engineer
Acordex Imaging Systems
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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