PDA

View Full Version : How to stop network operation?



newtolinux
17th January 2011, 07:22
Hi...
I am sending a large file over a network by using QNetworkAccessmanager's post method

QNetworkReply *reply = manager->post(request, postDataByteArray);
reply finished signal will be emitted once the entire post operation is complete. untle that networkaccessmanager keeps on sending the my large file.
But my question is can i interrupt that post operation in middle if i want. I could not find any proper apis in networkaccessmanager's documentation to achieve that.
Can some one suggest me how to solve this problem?

Coolcat
19th January 2011, 13:35
QNetworkReply has a method abort(). However, at least with Qt 4.6 there is a bug, which make this unusable. I don't remember what exactly the problem was, but there was already a bug report. This is what I noted in my source code:

// TODO/FIXME: This is a memory leak since the QNetworkReply might not be deleted.
// However, there is a bug in Qt 4.6.3 and 4.7.0 which results frequently in a segfault
// when calling abort or trying to delete the reply before it signals finished on its own.
m_queryReply = NULL;
So my "solution" for this is just to ignore the reply result if it should arrive later.

The bug report said the problem would be fixed in 4.7.x However, I did not tried yet with 4.7.1.