jboban
30th June 2012, 13:13
Is there any hidden problem with this code, please? I'w worried about living time of dynamic created "*connection" pointer.
void TMyTCPSrv::incomingConnection(int sockDesc)
{
TConnection *connection = new TConnection(this);
connection->setSocketDescriptor(sockDesc);
// Send read message to this
connect(connection, SIGNAL(toLocalServer(const QString&)),
this, SLOT(onReadFromClient(const QString&)), Qt::QueuedConnection);
}
class TConnection: public QTcpSocket
{
...
};
void TMyTCPSrv::incomingConnection(int sockDesc)
{
TConnection *connection = new TConnection(this);
connection->setSocketDescriptor(sockDesc);
// Send read message to this
connect(connection, SIGNAL(toLocalServer(const QString&)),
this, SLOT(onReadFromClient(const QString&)), Qt::QueuedConnection);
}
class TConnection: public QTcpSocket
{
...
};