Solved Correct way to delete QNetworkRequest?
-
I'm creating a QNetworkRequest on heap and then in QNetworkAccessManager::finished signal when I try to delete it, an exception is thrown. Unlike QNetworkReply there is no deleteLater method that I can use either?
-
No it does not.
-
Hi,
Don't create your request on the heap, there's no need for that.
-
@SGaist Basically I've created a custom struct to track each REST request. The custom struct (not QObject) contains associated QNetworkRequest and QNetworkReply pointers.
The issue is that I also delete REST request struct in QNetworkAccessManager::finished signal, so even if I create QNetworkRequest on stack inside my custom struct, my custom struct is created on heap and deleted inside the finished signal, so wouldn't that result in same error?
-
Why do you need to keep the request object ?
-
@SGaist I assumed it needs to be kept until the request is processed?
-
No it does not.
-
@SGaist Moved QNetworkRequest out of the struct and creating it just before the get call, seems to be working fine now.