C++ (Qt)socket->deleteLater();
C++ (Qt)socket_coming::socket_coming(QTcpSocket *soc):QObject(),socket(soc){ connect( socket, SIGNAL( disconnected() ), SLOT( slotDisconnected() ) );} void socket_coming::slotDisconnected(){ disconnect(..); disconnect(..); delete socket; emit socketDisconnected();}
C++ (Qt)void socket_thread::run(){ ... com=new socket_coming(socket); ... connect(com,SIGNAL(socketDisconnected()),this,SLOT(closeThread()),Qt::DirectConnection);} void socket_thread::closeThread(){ ... delete com; ...}
C++ (Qt)void main_widget::slotComingNewConnection(){ ... socket_thread *sock_thread=new socket_thread(coming_socket->socketDescriptor()); ... connect(sock_thread,SIGNAL(signalCloseThread()),sock_thread,SLOT(quit()),Qt::QueuedConnection); ...}