-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 track properties edit fix #14022
Conversation
…like tuning ore advanced modes we cannot parse.
Rebased to resolve conflicts. |
enum class [[nodiscard]] UpdateResult{ | ||
/// The value has been updated and changed. | ||
Updated, | ||
enum class UpdateResult { | ||
/// The value has been updated and changed. | ||
Updated, | ||
|
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.
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.
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.
Concretely: What is your rationale for removing the checks you removed in this PR?
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.
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:
mixxx/src/util/compatibility/qmutex.h
Line 32 in a4e61f9
[[nodiscard]] inline QT_MUTEX_LOCKER lockMutex(QMutex* pMutex) { |
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.
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.
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.
I think so. I have left an inline comment:
#14022 (comment)
m_trackRecord.updateGlobalKeyNormalizeText( | ||
keyText, | ||
mixxx::track::io::key::USER); | ||
displayKeyText(); |
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.
Here we need to call displayKeyText()
independent of the result of updateGlobalKeyNormalizeText()
because we either want to see the normalized value or the old.
Is there an agreement wrt the |
No agreement afaict. The type is made for error handling and error values should not be ignored. In the few cases they should, they can be documented explicitly using program logic (either explicitly ignore or check for them). If the check is unnecessary, the compiler can optimize them away. |
It looks like I have not made my point clear enough regarding [[nodiscard]]. We have this rule: A single reasonable void cast on a no discard function IMHO that does not introduce a programming error rectifies that our rule is violated. There was already such a void cast in the 2.5 branch. This PR would have introduce another. In addition it feels flawed to put a nodiscard on a type declaration, because it limits it use, it would belong to a function. I am happy to reintroduce error checks if you can draft them along with a note which error it will fix. |
That rule has been written without considering this usecase. referring back to it unconditionally right now makes no sense.
In the few instances where it makes sense to ignore the return value, use |
For my understanding the use case has been considered. We have set this rule to not clutter our code with I can confirm the view form the link. The discussion is around throwing an error, which will force error handling or breaking the program and the alterntive of forcing error handling by See also:
In our case we have no reason to force error handling because there is nothing reasonable to handle IMHO. We do not not introduce a bug or anything so we don't need hard thinkining and hint later readers that we have ignored here something deliberal in an exeptional way. The fucntion in question is here: mixxx/src/track/trackrecord.cpp Line 30 in ae2dc10
|
Due to normalization, there are actually 4 different cases (given
So it's not really about error handling, but about optimizing the synchronization I think that removing |
@Swiftb0y Is it OK to merge now? |
Sorry, I have missed the ping previously. Thank you @cr7pt0gr4ph7 for the detailed explanation. It has motivated to me to indeed take another deep look at the surrounding code and can see how |
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.
LGTM. Thank you.
This fixed reloading and deleting of key value in the Track properties dialog.
These are the leftover commits form the key metadata handling PRs for #10890