Ticket UUID: | 067306a206168ccb29a47f1944b3f7c3ff419e21 | |||
Title: | Aqua: use isEqualToString: to check appearance names | |||
Type: | Patch | Version: | core-8-6-branch | |
Submitter: | chrstphrchvz | Created on: | 2025-08-10 02:40:07 | |
Subsystem: | 66. Aqua Window Operations | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Open | Last Modified: | 2025-08-15 21:39:13 | |
Resolution: | None | Closed By: | nobody | |
Closed on: | ||||
Description: |
Since the type NSAppearanceName is just NSString *, are appearance names supposed to be checked using the isEqualToString: method rather than with == (pointer comparison)? Example: --- macosx/tkMacOSXColor.c +++ macosx/tkMacOSXColor.c @@ -447,7 +447,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin) } else { name = [[NSApp effectiveAppearance] name]; } - return (name == NSAppearanceNameDarkAqua); + return [name isEqualToString:NSAppearanceNameDarkAqua]; } #else (void) tkwin; | |||
User Comments: |
marc_culler (claiming to be Marc Culler) added on 2025-08-15 21:39:13:
NSAppearanceName is a "Type Alias" for NSString, and the name property of NSAppearance is of type NSAppearanceName. i.e. the documentation says: Type Alias NSAppearanceName typedef NSString * NSAppearanceName; My understanding is that when Apple does this sort of thing they use singleton NSString objects. So all NSAppearance objects with name NSAppearanceNameAqua actually do use equal pointers for their name property. It would make sense to do that, in order to make equality testing faster, given that there are only a few possibilities for a "System Appearance Name". However I can not find any explicit statement guaranteeing that the System Appearance Names used for the name property are actually singletons. So I think the current code works, but that your suggestion would be safer in some sense. |
