Well, my new code is working and I can download more then one file at a time. I still need to work on the queue part but first I am having a problem removing the QHttp object when the request is finished. Here is my code:
void SSDownloaderMWI::httpRequestFinished(int requestId, bool error)
{
QHttp *sendHttp
= qobject_cast<QHttp
*>
(sender
());
QList<QTableWidgetItem
*> items
= downloadsTW
->findItems
(QString::number(requestId
), Qt
::MatchFixedString);
if(items.count() != 0)
{
int workingRow = items.at(0)->row();
file->setFileName(downloadsTW->item(workingRow, 10)->text());
file->close();
if(error)
{
file->remove();
finishedStatus->setText("Error");
}
downloadsTW->setItem(workingRow, 4, finishedStatus);
downloadsTW->setItem(workingRow, 8, requestIdItem);
int index = httpPointers.indexOf(sendHttp);
httpPointers.removeAt(index);
//delete sendHttp;
}
}
void SSDownloaderMWI::httpRequestFinished(int requestId, bool error)
{
QHttp *sendHttp = qobject_cast<QHttp *>(sender());
QList<QTableWidgetItem*> items = downloadsTW->findItems(QString::number(requestId), Qt::MatchFixedString);
if(items.count() != 0)
{
int workingRow = items.at(0)->row();
QFile *file = new QFile();
file->setFileName(downloadsTW->item(workingRow, 10)->text());
file->close();
QTableWidgetItem *finishedStatus = new QTableWidgetItem("completed");
if(error)
{
file->remove();
finishedStatus->setText("Error");
}
downloadsTW->setItem(workingRow, 4, finishedStatus);
QTableWidgetItem *requestIdItem = new QTableWidgetItem("");
downloadsTW->setItem(workingRow, 8, requestIdItem);
QMessageBox::information(this,"this",QString::number(httpPointers.count()));
int index = httpPointers.indexOf(sendHttp);
httpPointers.removeAt(index);
QMessageBox::information(this,"this",QString::number(httpPointers.count()));
//delete sendHttp;
}
}
To copy to clipboard, switch view to plain text mode
index is valid as it returns 0 during my tests of only one download running. I get the following error when my program crashes under debug:
rogram received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223771584 (LWP 9087)]
0xb718ae23 in memmove () from /lib/tls/i686/cmov/libc.so.6
rogram received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223771584 (LWP 9087)]
0xb718ae23 in memmove () from /lib/tls/i686/cmov/libc.so.6
To copy to clipboard, switch view to plain text mode
Any ideas on what I am doing wrong?
Thanks
mAx
Bookmarks