According to the following publication, an emitted signal is generated only once when the current executable slot is completed.
Wait for SLOT to complete execution with Qt
I have an ssl juice based client-server communication application that is single-threaded.
connect(socket, &QSslSocket::readyRead, [&]() { myObject.Read(); });
The client and server send each other some user messages. Whenever a message is sent or received either, they send ACK bytes (00).
In most cases, I notice that when Read() is between execution, the next readyRead() is served! I put the debug statements at the beginning and at the end of myObject->Read() . They confirm that the start of debugging is called again and again. The same is observed at control points.
When too much data is received, the recursive stack stack is created by too many Read() s. This either slows down the application GUI or crashes.
Usually this recursion occurs when a client tries to send an ACK as part of myObject->Read() . During this time, readyRead() indirectly signaled and also serviced. However, the slot of the previous signal was still being processed.
Questions :
- Is it possible for the Qt framework to signal between them when the slot is still in the middle of the path (single stream)?
- How to fix this socket specific scenario?
Note :
- By default, for individual streams, Qt::ConnectionType is DirectConnection . I also tried with QueuedConnection , but the result is the same.
- myObject.Read() is quite complex and has many other function calls. If this causes problems, then let me know what I should look for. Wrong to write the actual code.
source share