-
Notifications
You must be signed in to change notification settings - Fork 1k
Segfault after changing contact alias #5495
Comments
https://wiki.qt.io/New_Signal_Slot_Syntax#New:_connecting_to_simple_function discusses connecting lambdas to slots, and how without the third "this" argument in your diff above, that the functor will not be disconnected, but with the argument, that the connection can be broken when the "this" object is destroyed:
Similarly in this stackoverflow post, there's a more thorough explanation: https://stackoverflow.com/a/19721153 I'm not really sure how this |
Avoid calling functor with invalid this, causing segfault when setting friend alias. Now, when "this" is destroyed, the connection will automatically be removed by Qt. Fix qTox#5495
For a bit more explanation, "this" (the |
Qt5 documentation at http://doc.qt.io/qt-5/signalsandslots.html explains: "[...] we provide /this/ as context in the call to connect(). The context object provides information about in which thread the receiver should be executed. This is important, as providing the context ensures that the receiver is executed in the context thread." Fixes qTox#5495.
Brief Description
OS: Linux Debian buster
qTox version: git master
Commit hash: 55ef1e0
toxcore: 0.2.8
Qt: 5.11.3
Hardware: Core2 duo
Reproducible: Almost Always
Steps to reproduce
Observed Behavior
Contact alias is changed and saved in config. qTox segfaults.
Expected Behavior
Contact alias is changed and saved in config.
Additional Info
Backtrace:
This patch seems to fix the problem, but someone with a better knowledge of Qt and C++ lambdas needs to explain why.
The text was updated successfully, but these errors were encountered: