-
Notifications
You must be signed in to change notification settings - Fork 668
DYN-6377: Restrict where OnNodeModified is called. #14656
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
Conversation
src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DSDropDownBase.cs
Outdated
Show resolved
Hide resolved
|
|
||
| private void SelectionChanged(object sender, SelectionChangedEventArgs e) | ||
| { | ||
| if (comboBox.SelectedIndex != -1) |
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.
Isn't -1 actually a valid value ? Unless it is not allowed to clear the current selection here or in a subclass.
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.
if you want to avoid introducing the field, I think the sender will be the combobox.
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.
yeah, I need the field anyways for Dispose though.
| selectedString = GetSelectedStringFromItem(Items.ElementAt(value)); | ||
| } | ||
|
|
||
| OnNodeModified(); |
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.
Is it fair to say that an api dev should not call this function and use updatemodelvaluecommand instead ? otherwise the node will not be marked as modified. Perhaps make the set internal at some point in the future ?
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.
Well, we need to be able to set SelectedIndex from the Revit dropdown nodes. I guess it could be protected. But maybe there are other situations where you want to be able to set the value without triggering updates?
src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DSDropDownBase.cs
Outdated
Show resolved
Hide resolved
| Warning(Dynamo.Properties.Resources.NothingIsSelectedWarning); | ||
| } | ||
|
|
||
| OnNodeModified(); |
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.
Is this function called when SelectedIndex property is set to a different value?
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.
No it's not
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.
Sorry, I didn't get it then, how does moving OnNodeModified here work in that case?
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.
When exactly is UpdateValueCore called in this case?
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.
Ok, I see, by moving it out of SelectedIndex, you are avoiding chances of an infinite loop, since SelectedIndex is changed in PopulateItems, which is incidentally called here: https://github.com/DynamoDS/DynamoRevit/blob/a1c5384651133ebab113dd0abfef5bd256ef51f0/src/Libraries/RevitNodesUI/GenericClasses.cs#L194 inside the BuildOutputAst function, am I right?
I think I would agree that calling PopulateItems in BuildOutputAst is a bad idea in the first place.
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.
Correct.
Since it's been that way for a while (7 years!), perhaps we could fix it back to working as it did before #14122 and look at improving in a separate task?
|
@twastvedt can a regression test be written for this or only in DSRevit? |
I think we don't need DSRevit. We'd just need a test nodeModel that subclasses DSDropdownBase and modifies the selected value in its Though, if as @aparajit-pratap suggests, we shouldn't really be allowing this (updating node value in |
|
|
Follow-up: https://jira.autodesk.com/browse/DYN-6516 |
* Restrict where OnNodeModified is called. * Clean up. * Dispose * No SuppressFinalize (cherry picked from commit f1f9b74)
Purpose
REVIT-215698 & https://jira.autodesk.com/browse/DYN-6377
#14122 fixed an issue where setting a dropdown's value (the
SelectedIndexproperty) programatically didn't cause the node to recompute (OnNodeModifiednever called, so AST never rebuilt). However, Revit selection nodes change the node's value inBuildOutputAst(populate items and updateSelectedIndex), causing an infinite loop. (It's surprising to me that it's ok to modify the node's value inBuildOutputAst. Is this something other nodes do?)This PR moves the call to
OnNodeModifiedup toUpdateValueCore, which is what is called when changing the node's value programatically, reducing the impact of #14122 and preventing the crash.Declarations
Check these if you believe they are true
*.resxfilesRelease Notes
Fix a crash when using Dynamo for Revit dropdown nodes.
Reviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of