Skip to content

[Helper] Remove default value on OptionGroup #5605

Closed
hugtalbot wants to merge 2 commits into
sofa-framework:masterfrom
hugtalbot:202507_remove_default_select_optiongroup
Closed

[Helper] Remove default value on OptionGroup #5605
hugtalbot wants to merge 2 commits into
sofa-framework:masterfrom
hugtalbot:202507_remove_default_select_optiongroup

Conversation

@hugtalbot
Copy link
Copy Markdown
Contributor

@hugtalbot hugtalbot commented Jul 10, 2025

Based on #5604

It seems weird to me that the first entry is by default the selected one.
This was problematic in the case of CollisionReponse response data field :

  • it gets populated at parse using all available response method
  • if a wrong value is given by the user, nothing allowed us to identify it since the by-default selected response was the first one (AugmentedLagrangian) which is obviously valid !

Here is my hacky solution. To be discussed :)

Real diff : cce4867


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@hugtalbot hugtalbot added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Jul 10, 2025
void setItemName( unsigned int id_item, const std::string& name );

///Get the vector of names available
type::vector<std::string> getItemNames();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any usage of this newly introduced method.

//////////////////////////////////////////////////////////////////////////////////////////////////////
OptionsGroup::OptionsGroup() : textItems()
{
selectedItem=0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly breaking. Even if not set here, selectedItem will have a default value. Might as well control it no ? Or add an internal mechanism that track if the optionGroup has been set at least once, to know if we can trust this attribute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. selectedItem will have a value if you define it or not. I don't see how it solves your problem. Could you imagine a fix in the CollisionResponse class instead?

@hugtalbot hugtalbot added pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Jul 16, 2025
@hugtalbot hugtalbot closed this Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix Fix a bug pr: status wip Development in the pull-request is still in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants