emacs-devel
[Top][All Lists]
Advanced

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

Re: Mac OS Sierra tab feature breaks C-x 5 2


From: Alan Third
Subject: Re: Mac OS Sierra tab feature breaks C-x 5 2
Date: Wed, 12 Jul 2017 19:23:21 +0100
User-agent: Mutt/1.7.2 (2016-11-26)

On Mon, Jul 10, 2017 at 10:22:43PM +0200, Anders Lindgren wrote:
> Now it compiles, but with a warning:
> 
> ----
> nsterm.m:7078:10: warning: instance method '-setTabbingMode:' not found
> (return type defaults to 'id') [-Wobjc-method-access]
>     [win setTabbingMode: NSWindowTabbingModeDisallowed];
>          ^~~~~~~~~~~~~~
> /System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:167:12:
> note: receiver is instance of class declared here
> @interface NSWindow : NSResponder <NSAnimatablePropertyContainer,
> NSUserInterfaceValidations, NSUserInterfaceItemIdentifica...
> -----
> 
> 
> I've seen other packages declare methods in NSWindows, but I don't know how
> "correct" that is. For example:
> 
> https://github.com/electron/electron/blob/master/atom/browser/native_window_mac.mm#L450

Yeah, I’m not sure about this either. It strikes me as a bit suspect,
but I don’t know that the alternatives are going to be any better.

We could disable the warning:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wobjc-method-access"
      if ([win respondsToSelector: @selector(setTabbingMode:)])
        [win setTabbingMode: NSWindowTabbingModeDisallowed];
    #pragma clang diagnostic pop

which is, I think, the right thing to do, but that’s quite messy
looking, and I suspect we’ll have to do the same for the gcc warning.
I don’t know if we’d then have to do some #ifdef stuff to separate the
clang and gcc stuff. This has the potential to get REALLY messy.

Another possibility is to cast `win` to `id`, which I’d guess would
look like:

    [(id)win setTabbingMode: NSWindowTabbingModeDisallowed];

That compiles here, no idea if it gets rid of the warning. It’s short
and sweet, but The Internet seems to think this is generally a bad
idea. I think we’d be OK since we’re only casting it once here, and as
we already know whether or not the method is available, type‐checking
(which we’re bypassing) doesn’t really give us anything.

By the way, while digging around I came across a lot of stuff saying
address@hidden(setTabbingMode)` should give a warning if `setTabbingMode`
doesn’t exist. Are you seeing one?
-- 
Alan Third



reply via email to

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