|
|
@ -135,6 +135,7 @@ class downloadThread : public QThread { |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
QStringList url_list; |
|
|
|
QStringList url_list; |
|
|
|
|
|
|
|
QStringList downloading_list; |
|
|
|
QMutex mutex; |
|
|
|
QMutex mutex; |
|
|
|
QWaitCondition condition; |
|
|
|
QWaitCondition condition; |
|
|
|
bool abort; |
|
|
|
bool abort; |
|
|
@ -160,7 +161,9 @@ class downloadThread : public QThread { |
|
|
|
|
|
|
|
|
|
|
|
void downloadUrl(QString url){ |
|
|
|
void downloadUrl(QString url){ |
|
|
|
QMutexLocker locker(&mutex); |
|
|
|
QMutexLocker locker(&mutex); |
|
|
|
|
|
|
|
if(downloading_list.contains(url)) return; |
|
|
|
url_list << url; |
|
|
|
url_list << url; |
|
|
|
|
|
|
|
downloading_list << url; |
|
|
|
if(!isRunning()){ |
|
|
|
if(!isRunning()){ |
|
|
|
start(); |
|
|
|
start(); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
@ -195,6 +198,11 @@ class downloadThread : public QThread { |
|
|
|
subThreads.removeAt(index); |
|
|
|
subThreads.removeAt(index); |
|
|
|
delete st; |
|
|
|
delete st; |
|
|
|
emit downloadFinished(url, path); |
|
|
|
emit downloadFinished(url, path); |
|
|
|
|
|
|
|
mutex.lock(); |
|
|
|
|
|
|
|
index = downloading_list.indexOf(url); |
|
|
|
|
|
|
|
Q_ASSERT(index != -1); |
|
|
|
|
|
|
|
downloading_list.removeAt(index); |
|
|
|
|
|
|
|
mutex.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){ |
|
|
|
void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){ |
|
|
@ -203,6 +211,11 @@ class downloadThread : public QThread { |
|
|
|
subThreads.removeAt(index); |
|
|
|
subThreads.removeAt(index); |
|
|
|
delete st; |
|
|
|
delete st; |
|
|
|
emit downloadFailure(url, reason); |
|
|
|
emit downloadFailure(url, reason); |
|
|
|
|
|
|
|
mutex.lock(); |
|
|
|
|
|
|
|
index = downloading_list.indexOf(url); |
|
|
|
|
|
|
|
Q_ASSERT(index != -1); |
|
|
|
|
|
|
|
downloading_list.removeAt(index); |
|
|
|
|
|
|
|
mutex.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|