In this case you need to make sure that
1) the connect to send(QString) uses connection type Qt:
irectConnection (the receiver thread does not run an event loop).
2) use a QMutex member in SocketThread to protect both accesses to message
void SocketThread
::send(QString message
) {
QMutexLocker locker
(&mutex
);
// assuming the mutex member is called mutex this->message = message;
}
void SocketThread::send(QString message)
{
QMutexLocker locker(&mutex); // assuming the mutex member is called mutex
this->message = message;
}
To copy to clipboard, switch view to plain text mode
while(1)
{
mutex.lock();
string string_in = message.toStdString();
mutex.unlock();
...
while(1)
{
mutex.lock();
string string_in = message.toStdString();
mutex.unlock();
...
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks