Tk Source Code

View Ticket
Login
Ticket UUID: 38e83e6ec9156c6aa8b9d73021b0528e99375799
Title: canvasText-1.11 fails on macOS (ditto for config-4.57)
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2018-04-30 16:29:34
Subsystem: 86. Test Tools Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-05-13 19:25:56
Resolution: Fixed Closed By: fvogel
    Closed on: 2018-05-13 19:25:56
Description:

canvasText-1.11 fails on macOS (not on other platforms) as follows:

==== canvasText-1.11 configuration options: bad value for "stipple" FAILED
==== Contents of test case:

    .c itemconfigure test -stipple xyz

---- Test completed normally; Return code was: 0
---- Return code should have been one of: 1
==== canvasText-1.11 FAILED

I.e. this call should error out (which is what's happening on Win and Linux) but it wrongly succeeds on macOS.

Analysis shows that:

- On Windows Tk_ConfigureWidget in ConfigureText() (tkCanvText.c) returns the expected error. This is not the case on macOS.

- On macOS, when specifying -stipple xyz, TkpGetNativeAppBitmap is called, which ends up in looking for an icon based on the given "xyz" name. This search for an icon always succeeds because the given name is less than 5 characters long, see OSTypeFromString

I don't really grok what the code in TkpGetNativeAppBitmap is doing, but I have checked that when the name of the stipple bitmap is longer than 4 characters then the test produces the expected error on macOS. This is the easiest fix making the test pass as expected, but perhaps there is a deeper issue here?

User Comments: fvogel added on 2018-05-13 19:25:56:
Merged to core-8-6-branch and trunk.

fvogel added on 2018-05-13 19:23:23:

Quoting (part of) a discussion I had by direct email with Marc Culler:

The specification is starting from the principle that one should be able to specify *any* bitmap to use as a stipple. The Tk interpreter cannot know what strings legitimately correspond to bitmaps on every host system.  So it seems that the principle is being interpreted to mean "try every possible method for generating a bit map from a string which is available on the host system and return the first bitmap which the system provides."  According to this, a failure arises only if the given string produces no bitmap after passing it to every available source of bitmaps on the host system.

Well, any string of length at most 3 is allowable as a filename extension.  And any filename extension can determine a file type if the system has been configured to recognize that extension.  On the Mac, every file type (including the unknown file type) has an associated file icon that can be used in the Finder.  And a file icon can be used as a bitmap.  So the principle requires that, on a Mac, any string of length at most 3 should be allowable as a stipple for the simple, but stupid, reason that you can provide any string of length at most 3 to the Mac OS and get a valid bitmap back.

[...]

Someone really might want to get the system icon for a file with extension .xyz so we really should not break TkpGetNativeAppBitmap while trying to fix this problem with the canvas item tests.

Conclusion: TkpGetNativeAppBitmap has no bug, and the tests using its output, once slightly modified to use more than 4 characters (see [2ac3c01849] and [6d66f25cb5]), now passes on all platforms and there is nothing more to do.


fvogel added on 2018-04-30 19:22:35:

Same cause for failure of config-4.57 on macOS only:

==== config-4.57 DoObjConfig - invalid bitmap FAILED
==== Contents of test case:

    testobjconfig alltypes .foo -bitmap foo

---- Test completed normally; Return code was: 0
---- Return code should have been one of: 1
==== config-4.57 FAILED

Same workaround committed in [6d66f25cb5]


fvogel added on 2018-04-30 19:03:29:

Workaround committed in [2ac3c01849]