QNetworkReply and deleteLater()

  • 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() .

    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);
        QUrl UrlWeather = (OnlinePath + "/weather?name="+ Nom_SD );
        QNetworkRequest requestWeather (UrlWeather);

    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);
              QString patternWeather = "<result>.*</result>" ;
              QRegExp regWeather(patternWeather);
              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.

  • Moderators

    so is this a question?

  • Qt Champions 2018

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

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

    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

  • Lifetime Qt Champion


    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.

  • 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 :

    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 ...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.