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
[Core] Fix Quantity construction with value as double + unit as string #5235
Conversation
2a4452f
to
3f41c0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch(...)
should be replaced with catch(const Base::Exception&)
I (stupidly) copied it from Line 110 in fb84f71
Should it be changed there also ? Can you give some more explanation on this in order to improve next contributions ? ANyway thx for merging, will now update #5232 accordingly and unleash it ;) |
Yes. Thanks for the hint. Searching for
In many articles about coding guidelines it's considered bad practice to always handle exceptions with (*) IIRC the parser in the past has thrown Base::Exception but now it throws Base::ParserError. So, in the corresponding catch handles we should use Base::ParserError instead. |
@wmayer Thx for details |
https://forum.freecadweb.org/viewtopic.php?f=3&t=64261&start=20#p552178
This PR fixes construction of quantity with 'Quantity(double, QString)' that because of Unit implicit conversion leads to weird :
Quantity(1.0, QStringLiteral("m")) ==> "1 mm"
Now :
Unit(QStringLiteral("m")).getUnit() ==> "mm"
but this looks correct to me as Unit has internally only unit dimensional awareness (no multiplier awareness)Quantity(1.0, QStringLiteral("m")) ==> "1 m"
This PR has impact on #5232 so should be merged or rejected first.
I checked that currently nowhere in the master was used the problematic 'Quantity(double, QString)' construction and that's fine (no current use).