-
Notifications
You must be signed in to change notification settings - Fork 293
refactor: Skip manual signal disconnection in descructors #607
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
Conversation
A boost::signals2::scoped_connection automatically disconnects on its destruction. https://www.boost.org/doc/libs/1_64_0/doc/html/boost/signals2/scoped_connection.html
A boost::signals2::scoped_connection automatically disconnects on its destruction. https://www.boost.org/doc/libs/1_64_0/doc/html/boost/signals2/scoped_connection.html
A boost::signals2::scoped_connection automatically disconnects on its destruction. https://www.boost.org/doc/libs/1_64_0/doc/html/boost/signals2/scoped_connection.html
A boost::signals2::scoped_connection automatically disconnects on its destruction. https://www.boost.org/doc/libs/1_64_0/doc/html/boost/signals2/scoped_connection.html
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.
Code review ACK 512072f.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
Code review ACK 512072f
To not forget about this, would be nice to add a doc comment at the top of the HandlerImpl
class and MakeHandler(boost::signals2::connection)
explaining that the returned Handler
disconnects the signal when the object is destructed.
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.
ACK 512072f
Confirmed PR description, and compiled and ran locally.
Would you mind having a look into this PR? |
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.
Tentative code review ACK 512072f. For all the commits except the first commit, the destructors are non-empty, so this PR changes behavior by disconnecting signals after the other code in the destructor instead of before the other code in the constructor. In theory this could be a problem if a new signal is sent while the object is being destroyed. Previously the signal would be ignored, now it could call methods on a half destroyed object.
It would be good if commit messages acknowledged the delayed disconnection of signals, and perhaps explained why it was safe to delay disconnecting signals.
During destruction, only one thread has access to the object, right? |
The lambdas passed to handleNotification methods are capturing Overall, I would guess this PR is probably safe, I just think it could use a better explanation of how it is safe. |
Thank all of reviewers for your reviews. Going to close this PR to do not raise safety concerns. |
Internally,
interfaces::HandlerImpl
keeps a member of theboost::signals2::scoped_connection
typegui/src/interfaces/handler.cpp
Line 21 in 192d639
Therefore, manual disconnections are redundant in class destructors.