Hi, I've got a problem with my HttpClient, when I'm trying to stop/cancel request my application crashes... How can I cancel it properly ?
After when I'm trying to stop by this function:
void HttpClient::stop(){
if(m_reply) {
m_reply->abort();
}
}
void HttpClient::stop(){
if(m_reply) {
m_reply->abort();
}
}
To copy to clipboard, switch view to plain text mode
it crashes on: loop.exec();
in function 'wait for finish'...
void HttpClient::waitForFinish(QNetworkReply *reply)
{
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
}
void HttpClient::waitForFinish(QNetworkReply *reply)
{
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
}
To copy to clipboard, switch view to plain text mode
{
if(url.isEmpty()){
Logger::getInstance()->Error(trUtf8("HttpClient: GET Response <Url is empty!>"));
}
m_reply = m_manager->get(*this->generateRequest(url, false));
waitForFinish(m_reply);
if(!m_reply){
return "";
}
... code
QString HttpClient::get(const QString &url)
{
if(url.isEmpty()){
Logger::getInstance()->Error(trUtf8("HttpClient: GET Response <Url is empty!>"));
}
m_reply = m_manager->get(*this->generateRequest(url, false));
waitForFinish(m_reply);
if(!m_reply){
return "";
}
... code
To copy to clipboard, switch view to plain text mode
This problem occurs sometimes, not always. I think that if, in another thread still performs and here is aborted it causes this crash...
Any idea ?
Thanks for any help
Bookmarks