-
Notifications
You must be signed in to change notification settings - Fork 735
The Qt example seems affected by race conditions #4
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
Comments
Thanks for reporting, I'm just start to use QT for this demo, what you guess about the thread is true, and the purpose I used Signals/Slots is to invoke the UI operations in UI thread. It seems I choose a wrong way? I'll try to verify. |
Hi, @lultimouomo I've test by set breaking point at |
You're right, I thought the connection type (i.e. whether to execute the slot in line or post an event on the loop) was chosen at connection time, according to the thread affinity of the sender and the receiver. |
Hi, @lultimouomo I think indicating Qt::QueuedConnection explicitly is not the good choice, AutoConnection is better than QueuedConnection in this case because If you did signal |
Hi,
I honestly just glanced the code, but the Qt example seems to invoking UI methods from the socket callbacks, which (I guess) are executed from an ASIO thread, not the main Qt one.
https://github.com/socketio/socket.io-client-cpp/blob/9663ca3c64a79c5bbd9f403fddd8a82e70f6f589/examples/QT/SioChatDemo/mainwindow.cpp#L41-43 should use Qt::QueuedConnection, otherwise the connected slots will be executed in line in the current thread.
The text was updated successfully, but these errors were encountered: