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?
From http://doc.qt.io/qt-5/qnetworkreply.html :
Note: Do not delete the object in the slot connected to this signal. Use deleteLater().
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
.
Puzzled. But that would delete the instance of QNetworkReply not QNetworkAccessManager, at the end of the slot. Does this in fact work on both items or do we also need to explicit deleteLater on the QNetworkAccessManager itself (and how best to access it, presume we do not need a second signal-slot connection for that). The documents are silent on that point, Going to go build up a test case with a few thousand calls to see, but other on the board surely know. dck
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.