When socket writes data i get the "QObject: Cannot create children for a parent that is in a different thread." error, but the data is transferred anyway, because client gets it. QTcpSocket has no parent. Could someone help me in solving this? (Qt 4.2)

Here is the run():
Qt Code:
  1. void XRServerThread::run()
  2. {
  3. m_socket = new QTcpSocket;
  4.  
  5.  
  6. //end if error occured
  7. if(! m_socket->setSocketDescriptor(m_socket_descriptor))
  8. {
  9. //-32300 - xr transport error
  10. emit error(XR_TRANSPORT_ERROR, QString("Socket error: %1")
  11. .arg(m_socket->error()));
  12. return;
  13. }
  14.  
  15. connect(m_socket, SIGNAL(readyRead()), this, SLOT(readFromSocket()));
  16. // connect(m_socket, SIGNAL(disconnected()), m_socket,
  17. //SLOT(deleteLater()));
  18. //exit the thread after disconnection
  19. connect(m_socket, SIGNAL(disconnected()), this, SLOT(quit()));
  20.  
  21. //start event loop
  22. exec();
  23. }
To copy to clipboard, switch view to plain text mode 
.
.
.

Here is the place where error occurs (m_socket->write()):
Qt Code:
  1. void XRServerThread::sendHttpResponse(int status_code, const QString &reason,
  2. QHttpHeader & headers, QString resp)
  3. {
  4. //This is the body of the response:
  5. QByteArray output;
  6. output.append(resp);
  7.  
  8. headers.setContentLength(output.size());
  9.  
  10. //This is the headers:
  11. QByteArray head_out;
  12. head_out.append(QString("HTTP/1.1 %1 %2\r\n")
  13. .arg(QString::number(status_code)).arg(reason));
  14. QStringList keys = headers.keys();
  15.  
  16. //creating string representation of headerss
  17. foreach(QString key, keys)
  18. {
  19. head_out.append(QString("%1: %2\r\n").arg(key).arg(headers.value(key)));
  20. }
  21.  
  22. head_out.append("\r\n");
  23.  
  24. //Write the headers out:
  25. m_socket->write(head_out);
  26.  
  27. //Write the body out:
  28. m_socket->write(output);
  29.  
  30. //Close the connection we will not write anything else
  31. m_socket->disconnectFromHost();
  32. m_socket->waitForDisconnected();
  33. }
To copy to clipboard, switch view to plain text mode