themagician
4th June 2015, 15:48
I have this class called HttpDownload Header (https://github.com/labyrinthofdreams/screenpicker/blob/dev/httpdownload.hpp) / Source (https://github.com/labyrinthofdreams/screenpicker/blob/dev/httpdownload.cpp). It's basically a simple wrapper for QNetworkReply. The objects are created here (https://github.com/labyrinthofdreams/screenpicker/blob/dev/mainwindow.cpp#L1555) when the user wants to open a new network link via the OpenDialog. That HttpDownload is then started here (https://github.com/labyrinthofdreams/screenpicker/blob/dev/downloadsdialog.cpp#L39) by calling its start method and added to a model that outputs to a QListView using a custom delegate. The QListView displays a progress bar for each HttpDownload which reports its progress via the model. It works. But if I then add another context menu here (https://github.com/labyrinthofdreams/screenpicker/blob/dev/downloadsdialog.cpp#L71) that lets you stop HttpDownload by calling a new method download->abort() whose implementation goes like this:
void HttpDownload::abort()
{
if(reply->isFinished()) {
return;
}
reply->abort();
emit updated();
}
Well that works too, however, after I've aborted one HttpDownload, all subsequent HttpDownloads won't start downloading. At all. They do nothing. So when I call the start (https://github.com/labyrinthofdreams/screenpicker/blob/dev/httpdownload.cpp#L45) method here (https://github.com/labyrinthofdreams/screenpicker/blob/dev/downloadsdialog.cpp#L41), it won't start downloading. Any ideas? I've tried replacing reply->abort() with reply->close() but it does the same thing. Thanks.
void HttpDownload::abort()
{
if(reply->isFinished()) {
return;
}
reply->abort();
emit updated();
}
Well that works too, however, after I've aborted one HttpDownload, all subsequent HttpDownloads won't start downloading. At all. They do nothing. So when I call the start (https://github.com/labyrinthofdreams/screenpicker/blob/dev/httpdownload.cpp#L45) method here (https://github.com/labyrinthofdreams/screenpicker/blob/dev/downloadsdialog.cpp#L41), it won't start downloading. Any ideas? I've tried replacing reply->abort() with reply->close() but it does the same thing. Thanks.