Tk Source Code

View Ticket
Login
Ticket UUID: 5f44d4f5ea47cb81c6fa66287cb721be80caedc1
Title: Tk with quartz doesn't compile on Mac OS X 10.6
Type: Patch Version: 8.6.6
Submitter: mojca Created on: 2016-08-24 10:09:31
Subsystem: 83. Mac OS X Build Assigned To: nobody
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2017-05-29 16:51:02
Resolution: Accepted Closed By: kevin_walzer
    Closed on: 2017-05-29 16:51:02
Description:
This patch broke building of quartz-based Tk on Mac OS X 10.6:
    http://core.tcl.tk/tk/info/c6301aba29addea1

The problematic part is

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

The middle line should be changed to

	scalefactor = ([[win backingScaleFactor] floatValue] == 2.0) ? 2 : 1;

otherwise the compiler complains about

    error: invalid operands to binary == (have ‘id’ and ‘double’)

Compiler needs to compile the contents of if-loop even if the condition will be false (but note that a binary compiled on 10.6 might run on 10.7 or newer where the condition will be true) and doesn't know that the function backingScaleFactor (that's not known at compile time) was supposed to return a number.

See the discussion around
    https://lists.macosforge.org/pipermail/macports-users/2016-August/041377.html
User Comments: kevin_walzer added on 2017-05-29 16:51:02:
Committed on trunk and core-8-6-branch; thanks to Mojca Miklavec for the patch.

kevin_walzer added on 2016-08-25 03:17:21:
Unfortunately, this patch breaks the build on 10.11. clang complains with this error:

/Users/kevin/tcl-tk-fossil/tk/unix/../macosx/tkMacOSXXStubs.c:901:18: error: 
      bad receiver type 'CGFloat' (aka 'double')

Any suggestions here? Given a choice between supporting an obsoleted version of the OS and the current one, my choice is for the current one.

Attachments: