Tk Source Code

View Ticket
Login
Ticket UUID: 31cd33dbf0af9600f9f13b03f07b7dbf0a42d1f4
Title: Cocoa Tk widgets do detect invalid -bitmap values
Type: Bug Version: 8.6.1
Submitter: ned.deily Created on: 2014-01-31 23:22:28
Subsystem: 66. Aqua Window Operations Assigned To: kevin_walzer
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2023-12-03 17:05:35
Resolution: None Closed By: marc_culler
    Closed on: 2023-12-03 17:05:35
Description:

When a non-existant bitmap file is given to a widget with X11 or Aqua Carbon Tk 8.4 on OS X, an exception is returned. But with Cocoa Tk 8.5 or 8.6 on OS X, the error is not detected by Tk but does result in an OS X error message.

With X11 Tk (MacPorts 8.6.1)

$ /macports/bin/wish8.6
% if [catch {button .b -bitmap "blah"} result] {
    puts "Failed: $result"
} else {
    puts "passed"
}
Failed: bitmap "blah" not defined)

With Cocoa Tk 8.6.1 or 8.5.15:

$ /usr/local/bin/wish8.6
% if [catch {button .b -bitmap "blah"} result] {
    puts "Failed: $result"
} else {
    puts "passed"
}
2014-01-31 14:58:07.134 Wish[9555:507] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: blah
passed

User Comments: marc_culler (claiming to be Marc Culler) added on 2023-12-03 17:04:42:
This has now been fixed (finally).

See [a54921d8e3] and [9be830f61b].

chrstphrchvz added on 2023-11-09 14:35:03:

The CFURLCopyResourceForKey warning was fixed; see [2fec274f].

However, there is still the behavior where bitmaps such as "blah" are not treated as invalid. This is due to an undocumented historical feature in Tk Aqua. TkpGetNativeAppBitmap() may interpret "blah" as the FourCC (“four-character code”) of an HFS filetype. If the system does not recognize the filetype, then one possible result is that a generic file icon is returned (although the actual behavior depends on macOS version and has varied in recent Tk releases).

Workaround: -bitmap bogus