Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

performSelectorOnMainThread & NSEventTrackingRunLoopMode



Hi,

I know what the problem is, this e-mail is to see if anyone has a workaround as I'm still trying to figure out the best solution. I'm also posting to warn others who might be doing something similar.

We use performSelectorOnMainThread to update UI components for a background worker thread. Exceptions occur when the user holds mouse down on a NSTextField/NSTextView and we change the text via a method triggered on the main thread. For example, let's say the text in the field is "some text", if we change it to be something short whilst the mouse is down, say: "n/a", you'll get an exception: e.g.:

*** -[NSBigMutableString characterAtIndex:]: Range or index out of bounds

or, I've also seen:

*** NSRunStorage, _NSBlockNumberForIndex(): index (0) beyond array bounds (0)

The modes parameter of performSelectorOnMainThread is set to [NSArray withObject:NSDefaultRunLoopMode], and you'd expect that to work since the mouseDown handler will run the loop in NSEventTrackingRunLoopMode. Unfortunately, if periodic events are enabled, which they will be whilst you're in an event tracking loop due to mouse down, queuePeriodicEvents (a framework function) runs the run loop in the default run loop mode. This is clearly a bug and I've reported it (rdar://5074339) and I'm sure others will have reported this too.

So, what I'm looking for is a way of being notified once we get back to the main event loop.

Any ideas?

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.