If I do not connect a slot to QNetworkAccessManager::finished() will QNetworkReply objects leak?



  • I assume, the QNR object created by the QNAM are created with the QNAM as their parents, so they will not "leak", they will indeed being deleted when their parent QNAM is deleted. However, if noone ever connects a finished slot to the signal, I assume the QNR are still created and kept around for all the lifetime of their parent QNAM. This will increase memory footprint over time. Is my assumption correct?



  • I am pretty sure their deletion is your responsibility. You can connect their finished signal to deleteLater slots to make sure they are not leaked.


  • Moderators

    [quote author="philk" date="1376174647"]I assume, the QNR object created by the QNAM are created with the QNAM as their parents[/quote]No, they're not. It's in the "documentation":http://qt-project.org/doc/qt-5.1/qtnetwork/qnetworkaccessmanager.html:
    [quote]After the request has finished, it is the responsibility of the user to delete the QNetworkReply object at an appropriate time. Do not directly delete it inside the slot connected to finished(). You can use the deleteLater() function.[/quote]


Log in to reply
 

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