a button IBActionin window A calls runModalForWindow:windowB.
windowB becomes key and modal.
windowB has a popUpWindowDatePicker that calls stopModalwhen displayed, and then popUpWindowDatePicker becomes the key, and windowB resigns and is not modal. no window is modal at this point.
when popUpWindowDatePicker is rejected, its method didResignFirstRespondersets the boolean to YES. windowB then becomes the key, and windowB windowController windowDidBecomeKeyNotificationstarts up, checks the boolean value and if that YES calls runModalForWindow:self.window.
now windowB is modal and key. windowA is still open but not a key.
windowB is "OK" and "Cancel", which cause:
[NSApp stopModalWithCode:returnCode]and then orderOut:, and closein okneB .
if popUpWindowDatePicker is used, and then at any time after that windowB is closed with the "OK" or "Cancel" key, a confirmation error is generated that includes the "OK" or "Cancel" buttons:
*** Assertion failure in -[NSButton lockFocus], /SourceCache/AppKit/AppKit-1038.29/AppKit.subproj/NSView.m:5237
-[NSButton(0x20021cd60) lockFocus] failed with window=0x20021c0c0, windowNumber=-1, [self isHiddenOrHasHiddenAncestor]=0
if windowB is closed using Okay or Cancel, and popUpWindowDatePicker is not used, there is no assertion error.
it seems that the sequence runModal-stopModal-runModal-stopModalin windowB is involved in the lockFocus failure on the pressed button, but I cannot find a way to trace more than this to solve this problem.
can anyone suggest any hints or thoughts?