Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make System language option work on macOS (fix getOSXSystemLang) #40034

Merged
merged 2 commits into from
Apr 30, 2020
Merged

make System language option work on macOS (fix getOSXSystemLang) #40034

merged 2 commits into from
Apr 30, 2020

Conversation

akirashirosawa
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

System language option does not work on MacOS. CFStringGetCStringPtr always return NULL. In Apple docs, I found that:

The functions that end with “Ptr” either return the desired pointer quickly, in constant time, or they return NULL. If the latter is the case, you should use CFStringGetCString.

https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/Articles/AccessingContents.html

Describe the solution

Add CFStringGetCString if CFStringGetCStringPtr returns NULL.
Also, I replaced reinterpret_cast with static_cast. Don't really know why reinterpret_cast is need here, if someone knows - feel free to change.

Describe alternatives you've considered

… if the code in question is not that performance-sensitive, you could simply call the CFStringGetCString function without even attempting to get the pointer first. (c) Apple docs

Testing

System language works correctly for MacOS.

Additional context

The functions that end with “Ptr” either return the desired pointer quickly, in constant time, or they return NULL. If the latter is the case, you should use CFStringGetCString. https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/Articles/AccessingContents.html
src/translations.cpp Outdated Show resolved Hide resolved
Co-authored-by: John Bytheway <[email protected]>
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments OS: macOS Issues related to macOS / OSX operating system labels Apr 30, 2020
@ZhilkinSerg ZhilkinSerg merged commit a67e503 into CleverRaven:master Apr 30, 2020
@akirashirosawa akirashirosawa deleted the akirashirosawa-fix-getOSXSystemLang branch May 1, 2020 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments OS: macOS Issues related to macOS / OSX operating system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants