-
Notifications
You must be signed in to change notification settings - Fork 0
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
function pointers for signal-slot connections in effects system #10
function pointers for signal-slot connections in effects system #10
Conversation
Ohh great, Thank you for the pull request! |
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 think we can improve the Lambda readability.
// pointer syntax if the slot has more parameters than the signal, so use a lambda | ||
// to hack around this limitation. | ||
connect(m_pControlMetaParameter, &ControlObject::valueChanged, | ||
this, [=](double value){slotEffectMetaParameter(value);} ); |
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 would prefere to explicit list the copied values. Here it is [this] I think.
Can we also explicit add the second parameter and remove the default?
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 a bit confused by C++'s lambda capturing feature. What is the benefit of listing specific variables when you can simply specify to capture whatever you need? Is it just to make the captured variables explicit?
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.
As far as I can tell, the only downside of default captures is the possibility of accidentally capturing more than intended.
https://stackoverflow.com/questions/6181464/do-c11-lambdas-capture-variables-they-dont-use
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.
For me [this] is more easy to read [=]. In case of a longer function it helps to protect the namespace and tells if we use a deep copy or not. On the other hand since there is no real downside. I don't mind.
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.
Okay, I'll use this
when it is the only captured parameter in the future. I'm okay leaving it how it is here though.
Qt 5 allows using function pointers for signal-slot connections instead of the hacky old SIGNAL and SLOT macros. The new syntax allows compile time type checking and IDEs can make sense of it. No more typos breaking connections!