gnustep-dev
[Top][All Lists]
Advanced

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

Re: NSWindow and delegate methods


From: Gregory Casamento
Subject: Re: NSWindow and delegate methods
Date: Tue, 17 Sep 2013 19:25:29 -0400

The fix is temporary until we determine why delegate methods are being called 
from self in the first place.  The changes will be improved once we have more 
information.

Gregory Casamento
address@hidden
Open Logic Corporation, President/CEO
GNUstep Lead Developer


On Sep 17, 2013, at 7:21 PM, Ivan Vučica <address@hidden> wrote:

> Hello all,
> 
> Gregory has added NSWindowDelegate as a formal protocol. That's great.
> 
> Unfortunately, it did break the build for me on Clang for a while. We talked 
> about it over XMPP, we noticed that there are some message sends for phantom 
> methods, and we decided to check to the mailing list about a possible 
> permanent fix.
> 
> Here's an example of the error:
> NSWindow.m:5098:23: warning: instance method
>       '-windowWillUseStandardFrame:defaultFrame:' not found (return type
>       defaults to 'id') [-Wobjc-method-access]
>       maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
>                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../Headers/AppKit/NSWindow.h:164:12: note: receiver is instance of class
>       declared here
> @interface NSWindow : NSResponder <NSCoding>
>            ^
> NSWindow.m:5098:15: error: assigning to 'NSRect' (aka 'struct _NSRect') from
>       incompatible type 'id'
>       maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
>               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Here's some context:
>   if ([_delegate respondsToSelector: 
> @selector(windowWillUseStandardFrame:defaultFrame:)])
>     {
>       maxRect = [_delegate windowWillUseStandardFrame: self defaultFrame: 
> maxRect];
>     }
>   else if ([self respondsToSelector: 
> @selector(windowWillUseStandardFrame:defaultFrame:)])
>     {
>       maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
>     }
> 
> There is no implementation of -windowWillUseStandardFrame:defaultFrame: in 
> NSWindow. I can also find no confirmation online that a subclass can 
> implement it. I'm not under OS X right now, so I cannot check, but it seems 
> to me that even if it's a valid thing to do, noone is doing it.
> 
> So what I would suggest we do is: we rip out the message send to 'self' for 
> these several relevant methods.
> 
> Greg's current fix is to add these declarations back to NSObject...
> @interface NSObject (NSWindowDelegateAdditions) <NSWindowDelegate>
> ...but that is kind-of wrong, as we're back where we started; the @protocol 
> could have been defined empty and everything could have remained in the 
> informal protocol.
> 
> Anyway -- since someone may depend on this behavior. Is there someone 
> depending on NSWindow's subclasses being able to implement 
> -windowWillUseStandardFrame:defaultFrame:, -windowShouldZoom:toFrame:, 
> -windowWillResize:toSize: and -windowShouldClose:? 
> 
> (These are the methods that broke for me when they were moved to the formal 
> protocol.)
> 
> Thanks!
> 
> -- 
> Ivan Vučica
> address@hidden
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev




reply via email to

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