On Sun, Dec 16, 2012, at 10:40 AM, Mike Abdullah wrote:
> 
> On 16 Dec 2012, at 17:20, Tamas Nagy wrote:
> 
> > Unfortunately that doesn't help. 
> > 
> > I think the issue should be related to dispatches, because it won't happen 
> > if I just call performSelectorOnMainThread...
> 
> Can you post that variant of your code then, please?

Now that I'm actually awake, I'm able to reproduce Tamas's issue with a
bare-bones Cocoa App on 10.7.5. Here's my app delegate:

@implementation AppDelegate

- (NSInteger)doOpenPanel:(id)unused;
{
    return [[NSOpenPanel openPanel] runModal];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
#if 0
    dispatch_async(dispatch_get_main_queue(), ^{
        [self doOpenPanel:nil];
    });
#else
    [self performSelector:@selector(doOpenPanel:) withObject:nil
    afterDelay:0];
#endif
}

@end

If you go with the dispatch approach, you get the eternal spinner, and
files never show up—or if they do, their QuickLook previews never show
up. Notably, you can still interact with the open panel. If you go with
-performSelector:::, it works fine.

My guess is that NSOpenPanel is doing some work on a background thread,
and that work is trying to use the main queue to inform the open panel
of its completion. By using the dispatch_async approach, the main queue
is blocked, and the background thread can't inform the open panel. The
-performSelector::: approach uses a timer, so the nested invocation of
the runloop that -runModal performs is still able to dequeue the
background task completion's block off the main queue.

--Kyle Sluder

_______________________________________________

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

This email sent to arch...@mail-archive.com

Reply via email to