Reputation: 9502
Say we have:
pManager = new QNetworkAccessManager();
QObject::connect(pManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(finishedSlot(QNetworkReply*)));
and
void finished(QNetworkReply* reply);
If we delete reply inside finished
we will get segfault. Does this mean we shall not free it?
Upvotes: 4
Views: 4483
Reputation: 1728
From http://doc.qt.io/qt-5/qnetworkreply.html:
Note: Do not delete the object in the slot connected to this signal. Use deleteLater().
Upvotes: 7
Reputation: 206689
From the QNetworkAccessManager
docs for the finished
signal:
Note: Do not delete the reply object in the slot connected to this signal. Use deleteLater().
So indeed, you should not delete it, but call deleteLater
.
Upvotes: 4