discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSApp stopModalWithCode:0];


From: Marc Bruenink
Subject: Re: [NSApp stopModalWithCode:0];
Date: Sat, 12 Aug 2006 13:51:59 +0200
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20051027

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]