FROM : j o a r
DATE : Sun Jan 13 21:06:28 2008
Hello,
Could this be a thread-safety problem? If you're using multiple
threads, are you sure that you're playing by the (barely documented)
rules?
j o a r
On Jan 13, 2008, at 11:52 AM, glenn andreas wrote:
> I've got code that makes a small thumbnail of another image by
> creating a new NSImage, lockFocus on it, and then drawing,
> unlocking, and autoreleasing it:
>
> NSImage *retval = [[NSImage alloc] initWithSize:newSize];
> [retval setCacheMode:NSImageCacheNever];
> [retval lockFocus];
> [preview drawInRect:NSMakeRect(0,0,newSize.width,newSize.height)
> fromRect:NSMakeRect(0,0,curSize.width, curSize.height)
> operation:NSCompositeCopy
> fraction:1.0];
> [retval unlockFocus];
> return [retval autorelease];
>
>
> Unfortunately, occasionally the lockFocus will crash:
> Program received signal: “EXC_BAD_ACCESS”.
> [Switching to process 19156 thread 0x3f23]
> (gdb) bt
> #0 0xfffeff10 in objc_msgSend_rtp ()
> #1 0x9141bc20 in _NXAllocateImageCache ()
> #2 0x9141b31c in -[NSCachedImageRep
> _initWithSize:depth:separate:alpha:allowDeep:] ()
> #3 0x9141b0a0 in -[NSImage lockFocus] ()
> #4 0x001330b4 in -[NSDictionary(QutilCorpse) previewOfSize:]
> (self=0x67e050, _cmd=0x174ee0, size=128) at /Volumes/Sources/qui/
> NSDictionary_QutilCorpse.mm:50
> (gdb) p newSize
> $1 = {
> width = 128,
> height = 128
> }
> (gdb) po retval
> NSImage 0x687e70 Size={128, 128} Reps=(
> )
>
>
> This only rarely happens, but it does happen, and seems to only
> happen on Leopard (10.5.1) - I tried adding the NSImageCacheNever
> line to try to see if it would go away based on some searching of
> the archives, but it didn't help. I really don't see what could
> possibly be wrong - it allocates the image of the correct size, and
> it really doesn't seem like lockFocus should crash (maybe throw an
> exception if, for some reason it couldn't lock focus, but not
> crash). Worse, this problem is very intermittent, so not a lot to
> test (I may see it every few days, sometimes a couple of times a day)
>
> Any ideas of how to work around this problem?
DATE : Sun Jan 13 21:06:28 2008
Hello,
Could this be a thread-safety problem? If you're using multiple
threads, are you sure that you're playing by the (barely documented)
rules?
j o a r
On Jan 13, 2008, at 11:52 AM, glenn andreas wrote:
> I've got code that makes a small thumbnail of another image by
> creating a new NSImage, lockFocus on it, and then drawing,
> unlocking, and autoreleasing it:
>
> NSImage *retval = [[NSImage alloc] initWithSize:newSize];
> [retval setCacheMode:NSImageCacheNever];
> [retval lockFocus];
> [preview drawInRect:NSMakeRect(0,0,newSize.width,newSize.height)
> fromRect:NSMakeRect(0,0,curSize.width, curSize.height)
> operation:NSCompositeCopy
> fraction:1.0];
> [retval unlockFocus];
> return [retval autorelease];
>
>
> Unfortunately, occasionally the lockFocus will crash:
> Program received signal: “EXC_BAD_ACCESS”.
> [Switching to process 19156 thread 0x3f23]
> (gdb) bt
> #0 0xfffeff10 in objc_msgSend_rtp ()
> #1 0x9141bc20 in _NXAllocateImageCache ()
> #2 0x9141b31c in -[NSCachedImageRep
> _initWithSize:depth:separate:alpha:allowDeep:] ()
> #3 0x9141b0a0 in -[NSImage lockFocus] ()
> #4 0x001330b4 in -[NSDictionary(QutilCorpse) previewOfSize:]
> (self=0x67e050, _cmd=0x174ee0, size=128) at /Volumes/Sources/qui/
> NSDictionary_QutilCorpse.mm:50
> (gdb) p newSize
> $1 = {
> width = 128,
> height = 128
> }
> (gdb) po retval
> NSImage 0x687e70 Size={128, 128} Reps=(
> )
>
>
> This only rarely happens, but it does happen, and seems to only
> happen on Leopard (10.5.1) - I tried adding the NSImageCacheNever
> line to try to see if it would go away based on some searching of
> the archives, but it didn't help. I really don't see what could
> possibly be wrong - it allocates the image of the correct size, and
> it really doesn't seem like lockFocus should crash (maybe throw an
> exception if, for some reason it couldn't lock focus, but not
> crash). Worse, this problem is very intermittent, so not a lot to
> test (I may see it every few days, sometimes a couple of times a day)
>
> Any ideas of how to work around this problem?
| Related mails | Author | Date |
|---|---|---|
| glenn andreas | Jan 13, 20:52 | |
| j o a r | Jan 13, 21:06 | |
| glenn andreas | Jan 13, 21:38 |






Cocoa mail archive

