Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to solve the assert failure

How to solve the assert failure

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 656 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by ManiRon
    #1

    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 ,

    MainWindow.cpp:

       void MainWindow::on_pushbutton_clicked()
      {
            ui->pushbutton->setDisabled(true);
    
           thread1.m_TargetIpAddress.setAddress(IP Address);
           thread1.m_iTargetPort  = ui->TargetPortNumber->text().toInt();
    
            thread1.start();
            thread2.start();
            }
    

    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);

         TargetConnectionStatus()
          {
              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 .

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Where are you creating the QTcpSocket objects ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved