summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2022-09-21 22:48:42 (GMT)
committermarc_culler <marc.culler@gmail.com>2022-09-21 22:48:42 (GMT)
commit9e1145446273a784e4fc723705e9115e7851006b (patch)
treeabb84adccc104d72b9a9843b6a800f7aae857e3c /macosx
parent477bda7275482083a0ab708a567df0a8791aebfc (diff)
parenta8a74ea23ed72d982a950ddfcebc9ff4fe16f845 (diff)
downloadtk-9e1145446273a784e4fc723705e9115e7851006b.zip
tk-9e1145446273a784e4fc723705e9115e7851006b.tar.gz
tk-9e1145446273a784e4fc723705e9115e7851006b.tar.bz2
Merge main
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXFileTypes.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/macosx/tkMacOSXFileTypes.c b/macosx/tkMacOSXFileTypes.c
index c5beb67..e5db49f 100644
--- a/macosx/tkMacOSXFileTypes.c
+++ b/macosx/tkMacOSXFileTypes.c
@@ -71,11 +71,16 @@ MODULE_SCOPE NSString *TkMacOSXOSTypeToUTI(OSType ostype) {
*/
MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
if (!initialized) {
initOSTypeTable();
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000
+// We don't have UTType but iconForFileType is not deprecated, so use it.
+ return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+#else
+// We might have UTType but iconForFileType might be deprecated.
if (@available(macOS 11.0, *)) {
+ /* Yes, we do have UTType */
UTType *uttype = [UTType typeWithIdentifier: filetype];
if (uttype == nil || !uttype.isDeclared) {
uttype = [UTType typeWithFilenameExtension: filetype];
@@ -92,16 +97,20 @@ MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
}
return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
} else {
-/* Despite Apple's claims, @available does not prevent deprecation warnings. */
-# if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
- return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
-#else
- return nil; /* Never executed. */
-#endif
- }
-#else /* @available is not available. */
+ /* No, we don't have UTType. */
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+ /* but iconForFileType is not deprecated, so we can use it. */
return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+ #else
+ /*
+ * Cannot be reached: MIN_REQUIRED >= 110000 yet 11.0 is not available.
+ * But the compiler can't figure that out, so it will warn about an
+ * execution path with no return value unless we put a return here.
+ */
+ return nil;
+ #endif
#endif
+ }
}
/*