- Started to implement drag n drop in feed list but it is still very buggy

This commit is contained in:
Christophe Dumez 2009-08-23 08:10:56 +00:00
parent b9f1586068
commit 2fa43dd973
7 changed files with 141 additions and 71 deletions

View file

@ -158,7 +158,9 @@ downloadThread::~downloadThread(){
abort = true;
condition.wakeOne();
mutex.unlock();
qDebug("downloadThread deleting subthreads...");
qDeleteAll(subThreads);
qDebug("downloadThread deleted subthreads");
wait();
}
@ -174,25 +176,31 @@ void downloadThread::downloadUrl(QString url){
void downloadThread::run(){
forever{
if(abort)
if(abort) {
qDebug("DownloadThread aborting...");
return;
}
mutex.lock();
if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){
QString url = urls_queue.dequeue();
mutex.unlock();
qDebug("DownloadThread downloading %s...", url.toLocal8Bit().data());
subDownloadThread *st = new subDownloadThread(0, url);
subThreads << st;
connect(st, SIGNAL(downloadFinishedST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadedFile(subDownloadThread*, QString, QString)));
connect(st, SIGNAL(downloadFailureST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadFailure(subDownloadThread*, QString, QString)));
st->start();
}else{
qDebug("DownloadThread sleeping...");
condition.wait(&mutex);
qDebug("DownloadThread woke up");
mutex.unlock();
}
}
}
void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, QString path){
qDebug("Downloading %s was successful", url.toLocal8Bit().data());
mutex.lock();
int index = subThreads.indexOf(st);
Q_ASSERT(index != -1);
@ -208,6 +216,7 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url,
}
void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){
qDebug("Downloading %s failed", url.toLocal8Bit().data());
mutex.lock();
int index = subThreads.indexOf(st);
Q_ASSERT(index != -1);