I'm modifying a large project written in Qt that spawns qthreads when certain requests come. Each of these threads write a QTcpSocket that is created in the main thread and connected to a server.
The thread class has a reference to the QTcpSocket. When needed writes to it, the socket write the data and calls waitForBytesWritten and then return.
The thread then waits on a condition until the readyRead signal is emitted from the socket.
Access on the socket is protected with a mutex.
The problem for me is that I see a lot of "QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread" warnings. This because I'm writing on the socket from another thread (the socket has been created in the main thread).
I know that the best solution should be using signals and slots to write and read but unfortunately the project is very complex and I don't have the time to change this behavior.
What can I do?
QTcpSocket
instance and use instead signal/slots. Compiler will show you all the places needed to be changed with generated compilation errors. – Max Go