Attachment "1ccface1c510-result.diff" to
ticket [1ccface1]
added by
chrstphrchvz
2022-09-23 18:05:29.
diff --git macosx/tkMacOSXFileTypes.c macosx/tkMacOSXFileTypes.c
index 66e4fbbc17..45149ec0ac 100644
--- macosx/tkMacOSXFileTypes.c
+++ macosx/tkMacOSXFileTypes.c
@@ -73,13 +73,9 @@ MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
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.
+ NSImage *result = nil;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
- /* Yes, we do have UTType */
UTType *uttype = [UTType typeWithIdentifier: filetype];
if (uttype == nil || !uttype.isDeclared) {
uttype = [UTType typeWithFilenameExtension: filetype];
@@ -91,25 +87,16 @@ MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
uttype = [UTType typeWithIdentifier:UTI];
}
}
- if (uttype == nil || !uttype.isDeclared) {
- return nil;
+ if (uttype != nil && uttype.isDeclared) {
+ result = [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
}
- return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
- } else {
- /* 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
+ return result;
}
#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+ result = [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+#endif
+ return result;
}
/*