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 improvements #4224

Closed
wants to merge 3 commits into from

Conversation

Holzhaus
Copy link
Member

No description provided.

@coveralls
Copy link

coveralls commented Aug 18, 2021

Pull Request Test Coverage Report for Build 1144431471

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 10 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 25.953%

Files with Coverage Reduction New Missed Lines %
src/engine/enginevumeter.cpp 1 90.24%
src/engine/cachingreader/cachingreader.cpp 9 71.38%
Totals Coverage Status
Change from base Build 1142817164: -0.01%
Covered Lines: 19995
Relevant Lines: 77044

💛 - Coveralls

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.

Good finding. I have no idea why the code has ever been written in such a complicated way. Maybe @daschuer knows?

// Called from update();
void emitValueChanged() override {
/// Called from `ControlEngineScriptLegacy::trigger`
void emitValueChanged() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to emitTrigger() while we are at it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or just trigger()?

Copy link
Contributor

@uklotzde uklotzde Aug 18, 2021

Choose a reason for hiding this comment

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

Should this become a private method and ControlEngineScriptLegacy a friend class then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should this become a private method and ControlEngineScriptLegacy a friend class then?

Hmm, I don't see a big problem with this method being part of the public interface. It may as well be used by the future controller engine implementation (and this class is only used in controller engines anyway).

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we should not mention by whom it is used in a comment, because public methods are supposed to be used by anyone.

emit trigger(get(), this);
/// Called from `ControlEngineScriptLegacy::trigger`
void trigger() {
emit triggered(get(), this);
}

signals:
// It will connect to the slotValueChanged as well
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated, but I don't understand this comment.

// Called from update();
void emitValueChanged() override {
emit trigger(get(), this);
/// Called from `ControlEngineScriptLegacy::trigger`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this comment then, because it is confusing. It's a public method that is accessible by anyone.

@@ -173,24 +154,9 @@ class ControlProxy : public QObject {
void valueChanged(double);

protected slots:
/// Receives the value from the master control by a unique direct connection
void slotValueChangedDirect(double v, QObject* pSetter) {
Copy link
Member

Choose a reason for hiding this comment

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

The different equal functions are there for the unique direct connection.

When one consumer is a in the same thread and one else is in another thread, we need two jump in addresses to maintain the unique connection. This was at least required when writing the code.

Did you check how Qt handles the situation today? If you are not certain we should keep the code as it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice the Qt::UniqueConnection flag. The documentation of this hacky code is insufficient. Unmaintainable.

Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this again, this code has been written having a single Proxy per Control in mind.
Today we have in many cases multiple proxies one for each connection, where this hacky code is not required.

Unfortunately it bypasses the quinine connection Flag. Two proxies in the same thread will lead to two queued up signals and two semaphores locked (if the qt code is kept the same since I have last looked into it)

Options:

  • leave this alone and revert to the single functions
  • dive into the qt code and clarify the situation
  • Introduce a less hacky solution that has another proxy layer one, one per receiving thread.

Maybe we can utilize a QThreadStorage for this ...

Copy link
Member

Choose a reason for hiding this comment

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

All has started with this bug: https://bugs.launchpad.net/mixxx/+bug/1406124

@daschuer
Copy link
Member

The situation has not changed up to the current "dev" version of Qt
https://github.com/qt/qtbase/blob/9ee429029371b56bb52871a503d74f755e1742c0/src/corelib/kernel/qobject.cpp#L3410

The uniqueness of the connection is verified by sender and receiver only, without comparing the connection type.
Since the uniqueness is an implementation detail of ControlProxy, we should keep the three slots to make it work in any case.

There is room fro improvements, after analyzing all use cases of ControlProxy and having the whole picture carved out.

While this PR only claims to clean up the code, we have a real issue to solve. This is the unverified use of pain pointers in case of direct connections from inside Qt. My original plan was to fix this and than finally add a feature that swaps out all engine data after the end of the audio call back at once.

See:
#1717
#1713

I would be happy to revive them.

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.

Trying to revert my approval ;)

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.

Seems I have to explicitly reject the PR to withdraw my approval.

@Holzhaus Holzhaus closed this Aug 19, 2021
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.

4 participants