To reply to my own post.  The problem lay in two things:

1) I had a bug in my selection constraining code that in a few odd places subtract a larger number from a smaller number when creating a range, thus creating a range with a really really big length--close to UINT_MAX. When you then try to draw a textview after scrolling, the textview doesn't like it.

2) The NSRange functions, in particular NSIntersectionRange(), don't handle numbers close to UINT_MAX. To be specific, if you have a range that the sum of the location and length is greater than UINT_MAX, NSIntersectionRange will wrap the result around which may make the range intersect in a way it really shouldn't. For example, if you have aRange {20, UINT_MAX-10}, and you do NSIntersectionRange ( aRange, NSMakeRange(0, [aString length]) ) --which is a quite common thing to do I think--as long as aString is longer than 20, the returned range will be {20, UINT_MAX-10}... not quite what you'd expect.

Anyway, I would have never run up against this if my code wasn't buggy, but I thought it might be helpful to someone down the line.

Peace,
->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

[EMAIL PROTECTED]
740.590.0009

On Mar 30, 2008, at 4:06 AM, Ben Lachman wrote:
I just added a call to scrollRangeToVisible: that is sometimes called from my text view's mouseDown method. Now, whenever scrollRangeToVisible: is called on a range that is not visible, the next drawRect of the text view crashes with the exception: "*** NSLayoutManager, _getGlyphBuffer(): NSZoneMalloc failed!" (EXC_BAD_ACCESS). I had assumed that this was just a memory management bug on my part, but the fact that I can basically turn the crash on or off based on whether I call scrollRangeToVisible has me a bit confused. Anyone know what this could be?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to