PDA

View Full Version : DisconnectFromHost generate a runtime error



Darthspawn
11th March 2010, 17:35
I have a qtcpSocket in a QThread, when i must disconnect, the program crash for a runtime error.



void ThreadSocket::run()
{
mpqtcp_Socket = new QTcpSocket(this);
connect (mpqtcp_Socket, SIGNAL (connected()), SLOT(SocketConnected()) );
//connect (mpqtcp_Socket, SIGNAL (connectionClosed()), SLOT(SocketClosed()), Qt::DirectConnection );
connect (mpqtcp_Socket, SIGNAL (disconnected()), SLOT(SocketClosed()));

connect (mpqtcp_Socket, SIGNAL (readyRead()), SLOT(SocketAnswer()), Qt::DirectConnection);
connect (mpqtcp_Socket, SIGNAL (error(int)), SLOT(SocketError(int)) );

mpqtcp_Socket->connectToHost (mqstr_Address, mint_Port);
exec();
}


disconnect code:



void ThreadSocket::Disconnect()
{
mpqtcp_Socket->disconnectFromHost();
mpqtcp_Socket->waitForDisconnected();
}


I'm doing something wrong? thanks in advance!

Sam