-
-
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
ControlProxy tweaks #4229
ControlProxy tweaks #4229
Conversation
f4093e9
to
f76c92e
Compare
f76c92e
to
fb29af1
Compare
Pull Request Test Coverage Report for Build 1151266515
💛 - Coveralls |
src/control/control.h
Outdated
@@ -37,7 +37,7 @@ class ControlDoublePrivate : public QObject { | |||
// Used to implement control persistence. All controls that are marked | |||
// "persist in user config" get and set their value on creation/deletion | |||
// using this UserSettings. | |||
static void setUserConfig(UserSettingsPointer pConfig) { | |||
static void setUserConfig(const UserSettingsPointer& pConfig) { |
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.
What is the purpose of passing a pointer by reference?
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.
Passing smart pointer that uses atomics internally for bookkeeping is a valid choice.
But in this case when taking ownership I would suggest to use pass-by-value + std::move which would resemble Rust's move semantics.
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.
Since QSharedPointer the underlying type of UserSettingsPointer is not movable this is the most efficient way to pass the pointer.
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 am unsure about the default control itself. Ideally it should ignore all invocations of set
and always return a default value, e.g. 0. Otherwise it might return varying values depending on by whom and when it is set and and by whom it is shared and read.
Due to race condition multiple default CO instances could be created. This makes debugging even more difficult.
src/control/control.h
Outdated
@@ -133,7 +134,7 @@ class ControlDoublePrivate : public QObject { | |||
} | |||
void deleteCreatorCO(); | |||
|
|||
ConfigKey getKey() { | |||
inline const ConfigKey& getKey() { |
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.
Please don't add redundant inline
direction within a class definition
The default CO is read only. So there should not be an issue with random values. |
bb389e9
to
98d1c9f
Compare
How do I know? Please add a comment for clarification. I didn't see why we can safely assume that this particular CO is never written. |
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.
If s_defaultCO is immutable then why should we use a QWeakPointer at all?? Allocating a single QSharedPointer that never gets out of scope would work perfectly fine then.
Than we have a leaking memory, valgind will complain about. Since it does not make a difference form the performance and uses the normal pattern to have not have a static shared pointer, I prefer using the weak pointer. |
Done |
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.
Thank you! LGTM
This fixes lp1942350 a regression from mixxxdj#4229
This fixes lp1942350 a regression from mixxxdj#4229
These are the tweaks form #1717 regarding the existing ControlProxy.
The new PollingControlProxy in #1717is now rebased on top of this.
Pleas see commit messages.