Nie moge dojsc co zle robie i jak to naprawic. Poprosze o pomoc.
klasa servera.cpp.
Server::Server(QObject *parent) :
QTcpServer(parent)
{
if(!this->listen(QHostAddress::Any,2234))
}
this->threadpool = new QThreadPool();
threadpool->setMaxThreadCount(10);
}
Server::~Server(){
this->close();
this->deleteLater();
}
void Server::incomingConnection(int handle){
Client * klient = new Client(handle);
this->threadpool->tryStart(klient);
// klient =0;
}
client.h
class Client: public QTcpSocket , public QRunnable
{
Q_OBJECT
public:
explicit Client(int d): QTcpSocket() {
this->setSocketDescriptor(d);
}
...
}
client.cpp
void Client::run(){
connect(this,SIGNAL(disconnected()),this,SLOT(removeClientFromList()));
connect(this,SIGNAL(connected()),this,SLOT(addClientToList()));
connect(this,SIGNAL(readyRead()),this,SLOT(readData()));
connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(connectionError(QAbstractSocket::SocketError)));
emit connected();
}
void Client::addClientToList(){
this->write("agggggggggggggggggggggggggggggggsg");
}
Client::~Client(){
this->abort();
}
SocketNotifier: socket notifiers cannot be disabled from another thread
QSocketNotifier: socket notifiers cannot be disabled from another thread
ASSERT failure in QCoreApplication: "Cannot send events to objects owned by a different thread. Current thread 3dce40. Receiver '' (of type 'QNativeSocketEngine') was created in thread 3d5088", file c:\ndk_buildrepos\qt-desktop\src\corelib\kernel\qcoreapplication.cpp, line 405
Nie moge dojsc co zle robie i jak to naprawic. Poprosze o pomoc.