Fred Kiefer wrote:
Marc Brünink schrieb:
if I send a [NSApp stopModalWithCode:0]; while I'm not in a modal
session I get a NSInvalidArgumentException. This is not engraved in the
Openstep Spec and behaves different in Cocoa. So I think this should be
changed. Anyone disagree? The bad thing about this one is that I do not
get the exception but a panel. So I am not able to catch it. Or......
I'm too sleepy. :-)
I think you are just wrong here. stopModelWithCode: should only be
called from within a modal session. It would not do much harm to not
raise an exception here, but some errors may go undetected then. You
should be glad that GNUstep tells you that your code is wrong, where
Cocoa seems to leave you in the dark.
Its just not stated anywhere. Neither the spec nor the documentation
mentioned an exception. At least as far as I had read them :-)
I don't have an idea what you are trying to do, but the documentation
states clearly that you should not call this method from outside the
event processing of a modal window. If you really need to call this
method you could work around by checking [NSApp modalWindow]first. But I
think this is wrong, but I cannot tell you a correct solution without
knowing the actual problem you are going to solve.
No. Its not about working around at all. This would not be a problem.
Its about understanding the behavior of GNUstep :-)
So I investigated a bit further. And now it starts to become really
weird. Ive the following code:
NS_DURING
[NSApp stopModalWithCode:0];
NS_HANDLER
NSLog(@"localException> %@", localException);
NS_ENDHANDLER
Which works as expected.
However as soon as I put this code into windowWillClose: it does not
work at all. The exception is caught, but the alert panel is raised
nevertheless.
Ciao
Marc
_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep