• 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
performSelectorOnMainThread & NSEventTrackingRunLoopMode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

performSelectorOnMainThread & NSEventTrackingRunLoopMode


  • Subject: performSelectorOnMainThread & NSEventTrackingRunLoopMode
  • From: Chris Suter <email@hidden>
  • Date: Wed, 21 Mar 2007 11:21:49 +1100

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: performSelectorOnMainThread & NSEventTrackingRunLoopMode
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Debugging Core Data unresolved keypath save error
  • Next by Date: Re: Detecting when menubar is visible
  • Previous by thread: Re: Copy/paste stop working, drag also, console says CoreDragCreate error: -4960
  • Next by thread: Re: performSelectorOnMainThread & NSEventTrackingRunLoopMode
  • Index(es):
    • Date
    • Thread