I have a QThread that contains a QUDPsocket (socket is member not local to QThread::run(), maybe I should change that from what I am reading). This QThread is instantiated in my QMainWindow class ie the GUI thread(I am not calling move to thread). Is it still safe to use waitForReadyRead or do I absolutly need to instantiate the QThread in main.cpp or call moveToThread() for it to be thread safe. I am getting intermittent double free exception inside the call to waitForReadyRead in the present way of doing it(sometimes I dont get it for days sometimes after 3 minutes).
Share
Have a look at the Qt documentation for
QUdpSocket. There is a note there explaining the class is reentrant. Also from the Qt documentation:Thus, to answer your question, it does not really matter what the parent of the
QThreadis, as long as you make sure that theQUdpSocketinstance you are using is instantiated within the context of the thread you are using it in.