introduce ControllerEngine::makeConnection and deprecate ControllerEngine::connectControl#1218
Conversation
…ests This fixes a bug in which calling the disconnect() method of script callback connection objects would disconnect all callbacks connected to its ControlObject. Also add debugging messages for connecting and disconnecting callbacks
|
|
||
| // Clear the m_connectedControls hash so we stop responding | ||
| // to signals. | ||
| m_connectedControls.clear(); |
There was a problem hiding this comment.
This did not have any practical effect because the connections are stored in ControlObjectScripts, so I removed this unnecessary member variable.
and ControllerEngineConnectionScriptValue -> ScriptConnectionInvokableWrapper
6ef0389 to
51d183b
Compare
|
I tried to make a wrapper for ControllerEngine::connectControl that could be invoked with
So I guess the best way forward is to document on the wiki how to use the connection objects returned by ControllerEngine::connectControl. |
…ed string for callback
e6424a3 to
1b5365d
Compare
… a block and add more tests, comments, and debugging messages
1b5365d to
482cafb
Compare
|
I refactored ControllerEngine::connectControl to quarantine the confusing behavior inside its own block. If you use code folding in your editor to collapse the block, the only weird thing about the function is that it checks whether the callback is a function twice (which it also did before this refactoring). |
and deprecate the confusing old ControllerEngine::connectControl function
|
Instead of leaving the confusing code as an isolated block with ControllerEngine::connectControl, I have moved the part of ControllerEngine::connectControl that actually makes the connections into a new script invokable function with a name that hints it returns an object: ControllerEngine::makeConnection. This new function only accepts JavaScript functions as callbacks (not strings of JavaScript source code, which the C++ side should only ever have to handle when loading a script file). It does not double as a way to remove connections; instead, scripts must store the returned connection object and call its |
|
Can someone review this? |
|
LGTM Thank you. |
|
I have updated the wiki to document I'll update Components to use |
This fixes a bug in which calling the disconnect() method of script callback connection objects would disconnect all callbacks connected to its ControlObject that shared a callback function. This created a very confusing situation when I accidentally created two Components that both connected the same components.Button.prototype.output function to the same ControlObject -- even though those callback functions would execute in different contexts and have different effects. I have also added tests for the quirky, inconsistent behavior of ControllerEngine::connectControl() and useful debugging messages.