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() .
https://forum.qt.io/topic/74409/problem-with-disassembler-and-sigill-signalAfter 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. -
@Amaury
so is this a question? -
@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);
intoaccessweather->get(requestWeather)->setParent(accessweather);
- or just call
rep->deleteLater();
insideAccueil::OnFinishWeath(QNetworkReply*rep)
- add
-
@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 -
Hi,
Might be a silly question but are you calling
accessweather->get(requestWeather);
in the same method that you createaccessweather
?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 :
https://www.raspberrypi.org/forums/viewtopic.php?t=59328&p=814919
https://bugs.launchpad.net/raspbian/+bug/1154042I 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 ...