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

Fix decimal separator handling when loading real numbers #4547

Merged
merged 3 commits into from
Sep 12, 2018

Conversation

PhysSong
Copy link
Member

  • Remove broken DataFile::LocaleHelper.
    When saving float values into QDomElement, Qt uses QString::setNum. As of Qt 4, the function always uses the C locale, so we don't need to worry about decimal separators when saving files.
    The problem is Qt5 doesn't provide a way to handle both period-separated(1.2) and comma-separated(1,2) real numbers in one function call because QString::toFloat always use the C locale only. QLocale::toFloat always tries its specific locale only.
  • Add new LocaleHelper.h and use it
    To solve the problem, I created a function which tries both period and comma. Using it will work on any platforms.

Fixes #4442.

@PhysSong PhysSong changed the title Fix float point handling due to locale issues Fix decimal separator handling due to locale Aug 21, 2018
@PhysSong PhysSong changed the title Fix decimal separator handling due to locale Fix decimal separator handling when loading real numbers Aug 21, 2018
@JohannesLorenz
Copy link
Contributor

I could code-read and test this branch. Let me know when it's ready.

@PhysSong
Copy link
Member Author

I used inline keyword to avoid errors for now. Should I move the definition to a source file instead?

@JohannesLorenz
Copy link
Contributor

@PhysSong Sounds good. Also maybe add doxygen-like comments so one can guess what the functions do by just looking at the header.

@PhysSong
Copy link
Member Author

There are some functions defined in other header files. I think my helper functions are not too large and it's fine to leave them inline.

Also maybe add doxygen-like comments so one can guess what the functions do by just looking at the header.

Updated the description at the beginning.

@PhysSong PhysSong merged commit f37ca49 into LMMS:stable-1.2 Sep 12, 2018
@PhysSong PhysSong deleted the locale branch September 12, 2018 02:02
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
Makes LMMS can handle both periods and commas properly when loading real numbers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants