Fix crash when opening second script in French C3D #9994
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please Note:
DynamoRevitrepo will need to be cherry-picked into all the DynamoRevit Release branches that Dynamo supports. Contributors will be responsible for cherry-picking their reviewed commits to the other branches after aLGTMlabel is added to the PR.Purpose
Fix crash when opening second script in French C3D
Steps to reproduce:
Helpmenu:Help>Samples>Core>Core_ListAtLevel.dynHelpmenu:Help>Samples>Core>Core_ListLacing.dyn.The exception arises when converting
1.0to double underfr-FRculture,in
GroupFontSizeToEditorEnabledConverter.Convert()onvalues[0].Questions:
Where does this
1.0come from?It is from
AnnotationView.xaml, whereFallbackValueof theVisibilityproperty is set to
1.0. When we switch from first dyn to the second, thecurrent workspace will be removed, triggered WPF binding updates.
Why it doesn't crash when we do the same operation in DynamoSandbox?
WPF actually doesn't follow
CurrentCultureorCurrentUICulturewhen resolving the binding (https://weblog.west-wind.com/posts/2009/Jun/14/WPF-Bindings-and-CurrentCulture-Formattings.
So by default, the
culturepassed to theConvertmethod is alwaysen-US.So it is OK.
How to reproduce with DynamoSandbox?
You have to manually add several lines of code to
DynamoSandboxentry fuction, it will crashalthough no exception dialog (interestingly, it pops up IE on my side).
Why does Civil 3D have
fr-FRculture?People buying Civil 3D will get Map 3D for free. The Map 3D dll,
Autodesk.Map.IM.Loader.dll,will override the Culture to be used by all WPF bindings, with the very similar code as above.
When I rename it, the crash goes away.
So how to fix?
At this stage, the safest fix would be simply changing
1.0to1.Later we should evaluate whether we really need to simply use the InvariantCulture
in all our binding coverters. We have unit tests for those converters, so also
need to remove/change them if decided to go that way.
Another way, we might should catch all the exception and
Converter.ToDouble()and use invariant culture if failed..Declarations
Check these if you believe they are true
*.resxfilesReviewers
Michael Kirschner
Aaran Tang
FYIs