• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Crash in lockFocus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Crash in lockFocus?


  • Subject: Crash in lockFocus?
  • From: glenn andreas <email@hidden>
  • Date: Sun, 13 Jan 2008 13:52:12 -0600

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?

Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build, mutate, evolve, animate




_______________________________________________

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


  • Follow-Ups:
    • Re: Crash in lockFocus?
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Change Background Color of IKImageBrowserView
  • Next by Date: Re: Crash in lockFocus?
  • Previous by thread: Re: Finder/iTunes Sidebar View?
  • Next by thread: Re: Crash in lockFocus?
  • Index(es):
    • Date
    • Thread