[Top][All Lists]

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

Re: [NSApp stopModalWithCode:0];

From: Fred Kiefer
Subject: Re: [NSApp stopModalWithCode:0];
Date: Sat, 12 Aug 2006 15:50:07 +0200
User-agent: Thunderbird (X11/20060527)

Marc Bruenink schrieb:
> 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 :-)
The Cocoa documentation states that you should not do this. So don't be
surprised when GNUstep raises an exception. This is meant to help you to
find your programming error.

>> 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 :-)

I still don't have a glue what you are about to do. As long as you don't
tell, I will only be able to give you abstract answers. Why would you
want to stop a modal window from outside the event loop. And if you do
so, why not use the abortModal, which is documented to do exactly this?

Trying to catch the exception is surely the worst thing to do here, but
I have to admit, I don't know, why this is failing for you. The only
thing that I see is that you did not use brackets {} in the code.

> So I investigated a bit further. And now it starts to become really
> weird. Ive the following code:
>    [NSApp stopModalWithCode:0];
>    NSLog(@"localException> %@", localException);
> 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.

reply via email to

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