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

Don't add duplicate options to the page #37548

Merged
merged 3 commits into from Feb 11, 2020

Conversation

ZhilkinSerg
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

Fixes #37534

Describe the solution

Check for duplicates before adding options to the their page.

Testing

Go to Options menu and see that Display option on Graphics tab is not duplicated anymore.

Additional context

While I am there, I've also added early return, so we don't iterate remaining pages once required page is found.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) labels Jan 30, 2020
@@ -135,7 +135,14 @@ void options_manager::addOptionToPage( const std::string &name, const std::strin
{
for( Page &p : pages_ ) {
if( p.id_ == page ) {
// Don't add duplicate options to the page
for( const cata::optional<std::string> &i : p.items_ ) {
if( i.has_value() && i.value() == name ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't duplicates be handled in the calling code? I mean something tries to add duplicate entries and that's weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, yes, DISPLAY option is added both through find_videodisplays and add_graphic_options.

We can probably go with RENDERER option way as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display shown twice in graphics settings
3 participants