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

Remove boilerplate and duplication in controller setting definition #13920

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

acolombier
Copy link
Member

As discussed in #13669, this PR introduced a refactor of the setting definition with a generic to remove code duplication and the needed boilerplate when introduced new setting type.

@acolombier acolombier marked this pull request as draft November 22, 2024 22:57
@acolombier acolombier force-pushed the feat/refactor-controller-setting branch from 172c8df to d4182ef Compare November 22, 2024 23:43
@acolombier acolombier marked this pull request as ready for review November 22, 2024 23:43
@acolombier acolombier force-pushed the feat/refactor-controller-setting branch from d4182ef to e6dbe5b Compare November 22, 2024 23:44
@acolombier acolombier requested a review from Swiftb0y November 22, 2024 23:46
src/controllers/legacycontrollersettings.h Outdated Show resolved Hide resolved
src/controllers/legacycontrollersettings.h Outdated Show resolved Hide resolved
Comment on lines -36 to +37
doc.setContent(QString(kValidBoolean).arg("false").toLatin1());
{
doc.setContent(QString(kValidBoolean).arg("false").toLatin1());
Copy link
Member

Choose a reason for hiding this comment

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

Was the removal of the heap allocation performance-motivated? If so I think there is a lot more we can improve here. Would you like some suggestions for that?

Copy link
Member Author

@acolombier acolombier Jan 18, 2025

Choose a reason for hiding this comment

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

Not really performance motivated since those tests are already sufficiently performant IMO (the whole suite run in ~1s on my machine), this is only because there was no need for it to be dynamically allocated

Copy link
Member Author

@acolombier acolombier Jan 18, 2025

Choose a reason for hiding this comment

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

Would you be okay to submit a commit to improve the tests?

Comment on lines +145 to +149
void reset() override {
m_editedValue = m_defaultValue;
emit valueReset();
}

Copy link
Member

Choose a reason for hiding this comment

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

I think there are some more members we could try to implement conditionally. For example we could automatically implement stringify if the underlying type supports that (using C++20 concepts of SFINAE). Same goes for value(). Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds like a great idea, although I wouldn't know how to do it. Would you be interested in submitting a commit to address that?

Comment on lines 236 to 242
using LegacyControllerSettingBase<SettingType>::m_savedValue;
using LegacyControllerSettingBase<SettingType>::m_defaultValue;
using LegacyControllerSettingBase<SettingType>::m_editedValue;
using LegacyControllerSettingBase<SettingType>::save;
using LegacyControllerSettingBase<SettingType>::reset;
using LegacyControllerSettingBase<SettingType>::connect;
using LegacyControllerSettingBase<SettingType>::changed;
Copy link
Member

Choose a reason for hiding this comment

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

can you explain why this is needed? The member functions should already be public while the member variables shouldn't be.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without this, I get error: ‘m_...’ was not declared in this scope
I believe this has to do with the multiple inheritance but I'm not quite sure tbh. Any better fix for that?

src/controllers/legacycontrollersettings.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants