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

ControlProxy tweaks #4229

Merged
merged 16 commits into from
Aug 20, 2021
Merged

ControlProxy tweaks #4229

merged 16 commits into from
Aug 20, 2021

Conversation

daschuer
Copy link
Member

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.

@daschuer daschuer mentioned this pull request Aug 19, 2021
@daschuer daschuer requested a review from Holzhaus August 19, 2021 08:02
@daschuer daschuer force-pushed the controlproxytweaks branch from f4093e9 to f76c92e Compare August 19, 2021 10:31
@daschuer daschuer force-pushed the controlproxytweaks branch from f76c92e to fb29af1 Compare August 19, 2021 15:38
@coveralls
Copy link

coveralls commented Aug 19, 2021

Pull Request Test Coverage Report for Build 1151266515

  • 38 of 46 (82.61%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.009%) to 25.958%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/control/control.cpp 21 25 84.0%
src/control/controlobject.cpp 9 13 69.23%
Files with Coverage Reduction New Missed Lines %
src/control/controlobject.cpp 1 89.66%
src/engine/enginevumeter.cpp 1 90.24%
Totals Coverage Status
Change from base Build 1148481046: 0.009%
Covered Lines: 20004
Relevant Lines: 77064

💛 - Coveralls

@@ -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) {
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@uklotzde uklotzde left a 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.

@@ -133,7 +134,7 @@ class ControlDoublePrivate : public QObject {
}
void deleteCreatorCO();

ConfigKey getKey() {
inline const ConfigKey& getKey() {
Copy link
Contributor

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

src/control/control.cpp Outdated Show resolved Hide resolved
src/control/control.h Outdated Show resolved Hide resolved
@daschuer
Copy link
Member Author

The default CO is read only. So there should not be an issue with random values.
You can however construct a case where this is bypassed.
Lets have a look what we can do against it.

@daschuer daschuer force-pushed the controlproxytweaks branch from bb389e9 to 98d1c9f Compare August 20, 2021 08:48
@uklotzde
Copy link
Contributor

uklotzde commented Aug 20, 2021

The default CO is read only. So there should not be an issue with random values.
You can however construct a case where this is bypassed.
Lets have a look what we can do against it.

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.

Copy link
Contributor

@uklotzde uklotzde left a 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.

src/control/control.cpp Outdated Show resolved Hide resolved
src/control/control.cpp Outdated Show resolved Hide resolved
src/control/control.cpp Outdated Show resolved Hide resolved
src/control/control.cpp Outdated Show resolved Hide resolved
src/control/control.cpp Show resolved Hide resolved
src/control/control.cpp Outdated Show resolved Hide resolved
@daschuer
Copy link
Member Author

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.

@daschuer
Copy link
Member Author

Done

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@uklotzde uklotzde merged commit 6ad1449 into mixxxdj:main Aug 20, 2021
@Holzhaus
Copy link
Member

Holzhaus commented Sep 1, 2021

daschuer added a commit to daschuer/mixxx that referenced this pull request Sep 1, 2021
This fixes lp1942350 a regression from mixxxdj#4229
daschuer added a commit to daschuer/mixxx that referenced this pull request Sep 1, 2021
This fixes lp1942350 a regression from mixxxdj#4229
@daschuer daschuer deleted the controlproxytweaks branch September 26, 2021 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants