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
i...@vucica.net
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to