You can only debug what you know is wrong. In this case, with my cursory knowledge of Qt, I know this code should work. (Well I know it doesn't but I don't know why.)

Problem description: I can start multiple apps and they can connect to one another, but as soon as a connection is terminated all of the apps segfault.

The problem is most assuredly within here:
Qt Code:
  1. void MSocketThread::run() {
  2. MSocket mSocket;
  3. if ( 0 != socketDescriptor ) {
  4. if ( !mSocket.setSocketDescriptor(socketDescriptor) ) {
  5. std::cerr << "Failed to set SocketDescriptor." << endl;
  6. }
  7. /* Output who joined the server */
  8. QHostAddress ipaddress = mSocket.peerAddress();
  9. QString ipString(tr("<font color=blue>%1 has joined.</font>").arg(ipaddress.toString()));
  10. emit relayIncomingText(ipString);
  11. }
  12. connect(&mSocket, SIGNAL(connected()),
  13. this, SIGNAL(connectionEstablished()));
  14. connect(&mSocket, SIGNAL(inboundText(QString)),
  15. this, SIGNAL(relayIncomingText(QString)));
  16. connect(this, SIGNAL(sigSend(QString)),
  17. &mSocket, SLOT(send(QString)));
  18. connect(&mSocket, SIGNAL(error()),
  19. this, SIGNAL(quit()));
  20. connect(&mSocket, SIGNAL(disconnected()), this, SLOT(quit()));
  21.  
  22. if ( 0 == socketDescriptor ) {
  23. mSocket.connectToHost(ip, port);
  24. }
  25.  
  26.  
  27. exec(); //Begin event loop.
  28. }
To copy to clipboard, switch view to plain text mode