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
simplify ControllerEngine::connectControl #656
Conversation
…nnectControl also make debugging and error messages more descriptive This fixes https://bugs.launchpad.net/mixxx/+bug/1458264 ('engine.connectionControl(group, control, function, true) connects control to a function rather than removes connection')
I noticed that the tests use a syntax that is not documented on the wiki (http://mixxx.org/wiki/doku.php/midi_scripting#automatic_reactions_to_changes_in_mixxx ): " connection = engine.connectControl('[Test]', 'potmeter', \n"
" 'testConnectDisconnectControlCallback');\n" and
As far as I can tell by grepping for '.disconnect(' in the source, only one mapping, the one for the Denon MC6000Mk2, users this convention and only on one line. Why is this available if it is not documented? Should the tests be modified to reflect the documentation, that is using engine.connectControl with true as the last argument? Should this feature be removed to simply controllerengine.cpp? Or should the wiki be updated to mention this? I think this feature is confusing because the wiki says connectControl should return true or false. |
QScriptValue function; | ||
ControllerEngineConnection conn; | ||
conn.key = ConfigKey(group, name); | ||
conn.ce = this; |
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.
can you rename this to something more significant like "conn.parent = this" or similar.
Thank you for the patch. |
Do you mean the disconnect() function specifically or disconnecting a CO from a script function in general? Disconnecting COs is essential for deck toggle buttons and programming different layers. |
I have not analyses what bad can happed due to the Qt locking. But in any case our connect and disconnect functions are not light weight. A a common dispatcher callback that calls the active deck callbacks would be a better solution. We should offer a library that includes a deck toggle layer that does not require connect and disconnect. For now I think we should keep disconnect and update the doku since this will keep the API unchanged. |
I can't think of a use case that would require (dis)connecting controls in a time critical loop, but it would be good to make a note of that on the wiki.
Yes, and I think the whole mapping system could really use an overhaul.
Agreed.
I would rather remove this almost unused and confusingly redundant functionality than document it. |
IMHO the original bug should be fixed in 1.12. The current approach from this PR suits to this. There should nothing against streamline this issue for master. Thoughts? |
This bug is not critical, it only affects script writers, and it is trivial to work around. I think the best fix for it is reorganizing the connectControl function, but I am also concerned that this could introduce regressions. |
The invocation of ".disconnect(" you found in my MC6000MK2 script is a On 07/20/2015 08:54 AM, Be-ing wrote:
|
Well then, I'm definitely in favor of removing the .disconnect() function and changing the tests to test the method that is actually documented on the wiki and used by scripts. |
@pwhelan , care to comment? |
I'm not clear about the purpose of this clause. When would the callback be a QObject? Should this clause be removed? |
Will be OK for me. Do we have conclusion about the target branch? |
This should be a short cut to re-connect a stored "conn" object. |
simplify ControllerEngine::connectControl improve debug messages in ControllerEngine::connectControl consolidate ControllerEngine::disconnectControl into ControllerEngine::connectControl remove ControllerEngine::disconnect
Now that it isn't overcomplicated and I understand what it's doing, I'd be more comfortable merging it into 1.12. With that functionality removed, the tests need to be updated before this is merged. |
@Be-ing I don't understand your question at all. |
I'm not really in favor of removing this. I actually use it quite a bit. I would be willing to document it on the wiki. |
@pwhelan , how do you use it? In what script? What is the advantage of using it rather than connectControl(..., true)? Why should this duplicate functionality be supported? |
@Be-ing: would you mind to prepare a 1.12 branch, that fixes the issue, but keeps the API? |
@Be-ing one huge advantage is that the context of the disconnect is clear, ie: in case there are multiple "callbacks" on the same CO with the same name. |
I've started a new branch to present the undocumented functionality in connectControl() in a cleaner way. |
Actually that was not the case. Calling the |
also make debugging and error messages more descriptive
This fixes https://bugs.launchpad.net/mixxx/+bug/1458264:
engine.connectionControl(group, control, function, true) connects control to a function rather than removes connection)
I tried writing a test to demonstrate the above bug but couldn't get the test to fail (on a branch without this commit of course). I did see that the bug was there because the test output showed the connection being made twice, but the logic of the test did not fail when this happened.