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

Gui: prevent crashes on MacOS using boost::format #9126

Merged
merged 1 commit into from Mar 31, 2023

Conversation

0penBrain
Copy link
Contributor

This PR is an attempt to solve crashes on MacOS described here :
https://forum.freecad.org/viewtopic.php?t=75442
https://forum.freecad.org/viewtopic.php?t=77234

@github-actions github-actions bot added WB Part Related to the Part Workbench WB Sketcher Related to the Sketcher Workbench labels Mar 30, 2023
@freecadci
Copy link

pipeline status for feature branch PR_9126. Pipeline 823352134 was triggered at 40e266d. All CI branches and pipelines.

@0penBrain
Copy link
Contributor Author

@wwmayer do you see any risk at merging this PR ? I just replaced all %i with %d which at worst shouldn't change anything.

@wwmayer
Copy link
Contributor

wwmayer commented Mar 31, 2023

According to https://www.boost.org/doc/libs/1_66_0/libs/format/doc/format.html#printf_directives using %i should be valid. But since %d is also valid it's worth a try.

@0penBrain
Copy link
Contributor Author

Yes %i is valid as is %d. But while both converts to decimal numbers, there are cases where 'such as in scanf where they are not equivalent.
Hence my present try. :)
I'm gonna merge and we'll see. If it's not enough, I may try change all %d to %.1d.

@0penBrain 0penBrain merged commit 8bea52a into FreeCAD:master Mar 31, 2023
7 checks passed
@wwmayer
Copy link
Contributor

wwmayer commented Mar 31, 2023

Yes %i is valid as is %d. But while both converts to decimal numbers, there are cases where 'such as in scanf where they are not equivalent.

Sooner or later we should move from boost::format to libfmt because for fmt::sprintf this library does some proper run-time checks whether the passed arguments match with the format specifiers. (From what I have read it can even do some compile-time checks with C++20.)

When using fmt::format (what I prefer) then for each argument {} can be used which will simplify things a lot. The compiler will find the right type automatically, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WB Part Related to the Part Workbench WB Sketcher Related to the Sketcher Workbench
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants