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

Key metadata improvements #14022

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

Key metadata improvements #14022

wants to merge 4 commits into from

Conversation

daschuer
Copy link
Member

These are the leftover commits form the key metadata handling PRs for #10890
They do not fix anything, but make the code more consistent.

@JoergAtGithub JoergAtGithub added this to the 2.5.1 milestone Dec 15, 2024
@daschuer
Copy link
Member Author

Rebased to resolve conflicts.

Comment on lines -19 to 22
enum class [[nodiscard]] UpdateResult{
/// The value has been updated and changed.
Updated,
enum class UpdateResult {
/// The value has been updated and changed.
Updated,

Copy link
Member

Choose a reason for hiding this comment

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

This tells me that the enum was deliberately made for error handling. Specifically Rejected should be checked because it almost always would require handling from the caller. This removes that feature, making the error checking optional (which I hope we can agree is very bad practice).

I need more explanation why its appropriate to weaken the guarantees this enum was supposed to provide.

Copy link
Member

Choose a reason for hiding this comment

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

Concretely: What is your rationale for removing the checks you removed in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have discussed this earlier and conclude that [[nodiscard]] is usefull if discarding is an error. In this case it is only an enum. Discarding can't be an error. It might be an error depending on the returning function. In our case it is updateGlobalKeyNormalizeText() wich works well without error checking. So the change allows us to remove static_cast<void>() on these calls. See at dlgtrackinfomulti.cpp

The counter example are places like this where [[nodiscard]] heps to avois programming errors:

[[nodiscard]] inline QT_MUTEX_LOCKER lockMutex(QMutex* pMutex) {

Copy link
Member

Choose a reason for hiding this comment

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

In this case it is only an enum. Discarding can't be an error.

Is it though? It seems that Rejected and Unchanged did need some special handling in some cases (which you have removed). I'm asking specifically why its fine to remove the handling for those cases here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so. I have left an inline comment:
#14022 (comment)

m_trackRecord.updateGlobalKeyNormalizeText(
keyText,
mixxx::track::io::key::USER);
displayKeyText();
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we need to call displayKeyText() independent of the result of updateGlobalKeyNormalizeText() because we either want to see the normalized value or the old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants