How to solve the assert failure

  • when i disconnect my server , the application throws an error saying

    ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread be0cf8. Receiver '' (of type 'QNativeSocketEngine') was created in thread cc39d4"

    I am not under standing what is causing the problem

    i have three threads running in my application ,


       void MainWindow::on_pushbutton_clicked()
           thread1.m_TargetIpAddress.setAddress(IP Address);
           thread1.m_iTargetPort  = ui->TargetPortNumber->text().toInt();

    1st thread :

    some of the socket operations like send , receive , connecttotarget , disconnectfrom host are done here

    2nd thread :

    i will connect to server from second thread.

    3rd thread :

    In this i will continuously send some command and receive some data from server.
    I am using while(var) , when ever connection is established this var value will be updated to one and when ever server disconnects var value is updated as 0(zero) . thread 3 will be started once connection is established with server .

    These are my sequence . Now my problem is when the server disconnects , I dont get the disconnected signal emitted from my application .

    this is my signal and slot

    connect(&obj, &QTcpSocket::disconnected,this,&MainWindow::TargetConnectionStatus,Qt::UniqueConnection);

              var = 0;

    as this slots is not being emitted the thread is continuously running and suddenly this assert failure occurs , How to solve this error .

  • Lifetime Qt Champion


    Where are you creating the QTcpSocket objects ?

Log in to reply