Problems with Modal Windows
Problems with Modal Windows
- Subject: Problems with Modal Windows
- From: Marc Weil <email@hidden>
- Date: Sat, 08 Mar 2003 17:40:51 -0500
Hello,
I am having a problem using runModalForWindow: in my app. First off, let me
tell you what I have set up.
I have a Trial Information window that contains how many days are left in
the user's trial, etc. It is a modal window (NSWindow). One of the options
in the window is to register the program by entering the serial number. When
this option is chosen, another modal window is opened that allows the user
to this (also an NSWindow). The trial info window remains open. If the user
enters a correct name/number combination, a message box is displayed using
NSRunInformationalAlertPanel() letting them know that the program is now
registered. When they dismiss this panel, the modal loop for the register
window is stopped and the window is closed. The trial info window (when it
regains Key status) has code in it that will halt its own modal loop and
close if the program is registered.
This all works fine, except that, after the trial info window closes,
clicked anywhere in the menu bar causes the program to crash with either a
Signal 10 (SIGBUS) or a Signal 11 (SIGSEGV). I am completely and totally
clueless as to why this is happening. Could it have anything it do with
juggling two modal loops at the same time? Btw, here is the code I use to
end the modal loop for the trial info window in the delegate method:
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
if([[aNotification object] isEqual: trialInfoWindow]) {
// [self selectionChanged: mnuTrialSelection];
if([[RegistrationModel sharedInstance] isRegistered]) {
[NSApp stopModal];
[[aNotification object] close];
}
}
}
The only thing I can think of as being the problem line is [NSApp stopModal]
since I am assuming that the modal loop for the trial info window is the
active modal loop (which seems logical). However, the program doesn't crash
while I am stepping through my own code in the debugger, only if I click on
one of the menu items in the menu bar after the trial info window closes.
Any ideas on this one?
TIA,
Marc Weil
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.