On 24 August 2016 at 04:37, Ryan Schmidt wrote:
>> On Aug 23, 2016, at 9:10 PM, Kevin Walzer  wrote:
>> On 8/23/16 10:04 PM, Ryan Schmidt wrote:
>>>
>>> This is weird because the backingScaleFactor method is supposed to return a 
>>> double, not an id, and is part of the Retina display API introduced in Mac 
>>> OS X 10.7. It is not in 10.6. The window should not be responding to the 
>>> backingScaleFactor selector on 10.6, so that if statement should never have 
>>> returned true and that code should never have been run.

Ryan, thank you very much for the analysis of the code.

>> While I'm not the author of that code, I did commit it, and you're right, it 
>> should not have run. What compiler is this error being triggered on?
>
> Apple gcc-4.2.1, the default compiler on Snow Leopard with Xcode 3.2.6.

It's more likely to happen with any compiler. (It's certainly
reproducible with clang 3.4.)

I might be wrong, but I suspect that

    if (win && [win respondsToSelector:@selector(backingScaleFactor)]) {
        scalefactor = ([win backingScaleFactor] == 2.0) ? 2 : 1;
    }

fails for the same reason as

    int a=0;
    if(a) {
        doSomethingCompilerDoesntWantYouToDo();
    }

does.

Sure, when executing the code, that "if" would resolve to false and
the loop wouldn't be entered. But the compiler doesn't know that in
advance. The compiler probably has to compile whatever is inside the
loop and complains about the type mismatch.

According to
    http://stackoverflow.com/questions/307128/how-do-i-cast-id-to-a-float
I guess that
    scalefactor = ([[win backingScaleFactor] floatValue] == 2.0) ? 2 : 1;
instead of
    scalefactor = ([win backingScaleFactor] == 2.0) ? 2 : 1;
should wok.

That compiles on 10.6 at least (I didn't check the actual
functionality, I don't even have GUI access to that 10.6 VM).

While it still throws
    tkMacOSXXStubs.c:901:23: warning: instance
      method '-backingScaleFactor' not found (return type defaults to
'id') [-Wobjc-method-access]
I guess that the warning is expected.

Mojca

(I guess that's beyond the scope of the users' mailing list, but well ...)
_______________________________________________
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users

Reply via email to