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. QNetworkReply and deleteLater()

QNetworkReply and deleteLater()

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.7k Views 3 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.
  • A Offline
    A Offline
    Amaury
    wrote on last edited by Amaury
    #1

    Hi there ,

    Last post on this forum I talked about a SIGILL signal that comes up in debug mode in my program on the app.exec() .
    https://forum.qt.io/topic/74409/problem-with-disassembler-and-sigill-signal

    After some research, I think I finally found where my problem is. It seems that when I initiate a QNetWorkRequest the QNetworkReply connected to my finished() SIGNAL seems to not be deleted.

    This is my .cpp

    QNetworkAccessManager *accessweather= new QNetworkAccessManager(this);
        connect(accessweather,SIGNAL(finished(QNetworkReply*)),this,SLOT(OnFinishWeath(QNetworkReply*)));
        connect(accessweather,SIGNAL(finished(QNetworkReply*)),accessweather,SLOT(deleteLater()));
    
    
        QUrl UrlWeather = (OnlinePath + "/weather?name="+ Nom_SD );
        QNetworkRequest requestWeather (UrlWeather);
        accessweather->get(requestWeather);
    
    

    Then I'm cutting the pieces of the content that I don't want with my SLOT "OnFinishWeath" like that

    void Accueil::OnFinishWeath(QNetworkReply*rep)
    {
        QByteArray ba = rep->readAll();
        QString contenu(ba);
    
    
        // RECUPERATION NOM MACHINE
              QString patternWeather = "<result>.*</result>" ;
              QRegExp regWeather(patternWeather);
    
              regWeather.indexIn(contenu);
              Weather = regWeather.cap(0);
              Weather = Weather.replace(0, 8,"");
              int posWeather = Weather.indexOf("<",0 );
              Weather = Weather.replace(posWeather,9,"");
    
    

    When in debug mode when I run the line accessweather->get(requestWeather); I find the SIGILL signal that chrashes my program.

    raven-worxR VRoninV 2 Replies Last reply
    0
    • A Amaury

      Hi there ,

      Last post on this forum I talked about a SIGILL signal that comes up in debug mode in my program on the app.exec() .
      https://forum.qt.io/topic/74409/problem-with-disassembler-and-sigill-signal

      After some research, I think I finally found where my problem is. It seems that when I initiate a QNetWorkRequest the QNetworkReply connected to my finished() SIGNAL seems to not be deleted.

      This is my .cpp

      QNetworkAccessManager *accessweather= new QNetworkAccessManager(this);
          connect(accessweather,SIGNAL(finished(QNetworkReply*)),this,SLOT(OnFinishWeath(QNetworkReply*)));
          connect(accessweather,SIGNAL(finished(QNetworkReply*)),accessweather,SLOT(deleteLater()));
      
      
          QUrl UrlWeather = (OnlinePath + "/weather?name="+ Nom_SD );
          QNetworkRequest requestWeather (UrlWeather);
          accessweather->get(requestWeather);
      
      

      Then I'm cutting the pieces of the content that I don't want with my SLOT "OnFinishWeath" like that

      void Accueil::OnFinishWeath(QNetworkReply*rep)
      {
          QByteArray ba = rep->readAll();
          QString contenu(ba);
      
      
          // RECUPERATION NOM MACHINE
                QString patternWeather = "<result>.*</result>" ;
                QRegExp regWeather(patternWeather);
      
                regWeather.indexIn(contenu);
                Weather = regWeather.cap(0);
                Weather = Weather.replace(0, 8,"");
                int posWeather = Weather.indexOf("<",0 );
                Weather = Weather.replace(posWeather,9,"");
      
      

      When in debug mode when I run the line accessweather->get(requestWeather); I find the SIGILL signal that chrashes my program.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Amaury
      so is this a question?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Amaury

        Hi there ,

        Last post on this forum I talked about a SIGILL signal that comes up in debug mode in my program on the app.exec() .
        https://forum.qt.io/topic/74409/problem-with-disassembler-and-sigill-signal

        After some research, I think I finally found where my problem is. It seems that when I initiate a QNetWorkRequest the QNetworkReply connected to my finished() SIGNAL seems to not be deleted.

        This is my .cpp

        QNetworkAccessManager *accessweather= new QNetworkAccessManager(this);
            connect(accessweather,SIGNAL(finished(QNetworkReply*)),this,SLOT(OnFinishWeath(QNetworkReply*)));
            connect(accessweather,SIGNAL(finished(QNetworkReply*)),accessweather,SLOT(deleteLater()));
        
        
            QUrl UrlWeather = (OnlinePath + "/weather?name="+ Nom_SD );
            QNetworkRequest requestWeather (UrlWeather);
            accessweather->get(requestWeather);
        
        

        Then I'm cutting the pieces of the content that I don't want with my SLOT "OnFinishWeath" like that

        void Accueil::OnFinishWeath(QNetworkReply*rep)
        {
            QByteArray ba = rep->readAll();
            QString contenu(ba);
        
        
            // RECUPERATION NOM MACHINE
                  QString patternWeather = "<result>.*</result>" ;
                  QRegExp regWeather(patternWeather);
        
                  regWeather.indexIn(contenu);
                  Weather = regWeather.cap(0);
                  Weather = Weather.replace(0, 8,"");
                  int posWeather = Weather.indexOf("<",0 );
                  Weather = Weather.replace(posWeather,9,"");
        
        

        When in debug mode when I run the line accessweather->get(requestWeather); I find the SIGILL signal that chrashes my program.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        @Amaury said in QNetworkReply and deleteLater():

        QNetworkReply connected to my finished() SIGNAL

        You have no such a thing... you have connect(accessweather,SIGNAL(finished(QNetworkReply*)),accessweather,SLOT(deleteLater())); that deletes the manager, not the reply.

        • add connect(accessweather,&QNetworkAccessManager::finished,[](QNetworkReply* reply)->void{reply->deleteLater();});
        • or change accessweather->get(requestWeather); into accessweather->get(requestWeather)->setParent(accessweather);
        • or just call rep->deleteLater(); inside Accueil::OnFinishWeath(QNetworkReply*rep)

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Amaury
          wrote on last edited by Amaury
          #4

          @raven-worx
          sorry wasn't explicit but I need to know what I am doing wrong with the delateLater function

          @VRonin
          none of this solutions seems to work I still have the SIGILL signal for the last two proposition and have a protected issue for the first one .

          EDIT : The program isn't even running my SLOT " OnFinishWeath" and crashes When I press F10 or F11 in debug mode on my accessweather->get(requestWeather); function

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

            Hi,

            Might be a silly question but are you calling accessweather->get(requestWeather); in the same method that you create accessweather ?

            If not, you have a member variable called accessweather that you shadowed when constructing it.

            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
            0
            • A Offline
              A Offline
              Amaury
              wrote on last edited by Amaury
              #6

              Yes I'm calling accessweather->get(requestWeather); in the same method.

              I just found something that might be usefull to those who have this problem .

              It seems that on Raspberry Pi there is some troubles by using the QNetworkAccesManager :
              https://www.raspberrypi.org/forums/viewtopic.php?t=59328&p=814919
              https://bugs.launchpad.net/raspbian/+bug/1154042

              I didn't understand everything , if there's something to do to stop those signals on Raspberry pls explain to me for now I just inhibited SIGILL signals since it comes only from here ...

              1 Reply Last reply
              0

              • Login

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