Modal sheet / dialog + thread == main app thread hangs ?
Modal sheet / dialog + thread == main app thread hangs ?
- Subject: Modal sheet / dialog + thread == main app thread hangs ?
- From: Marc Wandschneider <email@hidden>
- Date: Sun, 18 Oct 2009 12:51:45 +0800
I'm in the midst of debugging an extremely unusual problem, and I was
wondering if anybody might have any insight into what might be going
wrong:
In a controller class from a NIB, I take an NSPanel I from that same
NIB, and then show it app modally on an NSWindow (that was created by
hand in code):
[[NSApplication sharedApplication] beginSheet: myPanel
modalForWindow: window
modalDelegate: self
didEndSelector:
@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: myPanel];
now, when the "finish button is clicked", i run some code to disable
some buttons an fire off a thread to make sure the user input is valid
(i have to validate with a remote service). This thread is fired from
a separate validator object I create:
* setEnabled NO on a few controls
* setHidden NO on a control
// validator object
validateInfo: (NSDictionary *)parms notify: (SEL)notifySelector
onObject: (id)notifyObject
{
// build up data with parms and notify info
[[NSThread detachNewThreadSelector: @selector(remotevalidate:)
toTarget: self withObject: data];
}
next, when the validation is finished, the validator notifies my
controller object:
[notifyObject performSelectorOnMainThread: notifySelector
withObject: results waitUntilDone: NO];
and then my controller object, in the method that the validator object
calls, kills the dialog:
- (void)validationComplete: (id)data
{
[[NSApplication sharedApplication] stopModal];
[createTwitterPanel orderOut: nil];
[[NSApplication sharedApplication] endSheet: createTwitterPanel
returnCode: NSOKButton];
}
My problem: the top runModalForWindow does not exit until some system
event is sent to the window that was showing the dialog. trying to
move, resize, or do anything to the window, or otherwise switching
away from the application suddenly causes method to exit and execution
to continue. no amount of waiting seems to help, otherwise, however.
An even further, more interesting clue is that the dialog has two
controls, a WebView and a TextField. Even if I restart things by
clicking on the window, TABbing between the two controls remains
screwed up — it simply never works again.
I've tried changing validationComplete: to instead post a notification
to the main thread, and I've also played with the waitUntilDone on the
performSelectorOnMainThread method, all to no effect.
Any ideas? Things I should try looking at?
Thanks,
marc.
_______________________________________________
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