|
|
@ -35,27 +35,30 @@ class subDeleteThread : public QThread { |
|
|
|
private: |
|
|
|
private: |
|
|
|
QString save_path; |
|
|
|
QString save_path; |
|
|
|
arborescence *arb; |
|
|
|
arborescence *arb; |
|
|
|
bool abort; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
subDeleteThread(QObject *parent, QString saveDir, arborescence *arb) : QThread(parent), save_path(saveDir), arb(arb), abort(false){} |
|
|
|
subDeleteThread(QObject *parent, QString saveDir, arborescence *_arb) : QThread(parent), save_path(saveDir) { |
|
|
|
|
|
|
|
arb = _arb; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
~subDeleteThread(){ |
|
|
|
~subDeleteThread(){ |
|
|
|
abort = true; |
|
|
|
qDebug("subDeleteThread successfuly deleted"); |
|
|
|
wait(); |
|
|
|
//wait();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
signals: |
|
|
|
// For subthreads
|
|
|
|
// For subthreads
|
|
|
|
void deletionSuccessST(subDeleteThread* st); |
|
|
|
void deletionSuccessST(subDeleteThread* st); |
|
|
|
void deletionFailureST(subDeleteThread* st); |
|
|
|
//void deletionFailureST(subDeleteThread* st);
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
void run(){ |
|
|
|
void run(){ |
|
|
|
if(arb->removeFromFS(save_path)) |
|
|
|
/*if(arb->removeFromFS(save_path))
|
|
|
|
emit deletionSuccessST(this); |
|
|
|
emit deletionSuccessST(this); |
|
|
|
else |
|
|
|
else |
|
|
|
emit deletionFailureST(this); |
|
|
|
emit deletionFailureST(this);*/ |
|
|
|
|
|
|
|
arb->removeFromFS(save_path); |
|
|
|
|
|
|
|
emit deletionSuccessST(this); |
|
|
|
delete arb; |
|
|
|
delete arb; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -99,13 +102,13 @@ class deleteThread : public QThread { |
|
|
|
if(abort) |
|
|
|
if(abort) |
|
|
|
return; |
|
|
|
return; |
|
|
|
mutex.lock(); |
|
|
|
mutex.lock(); |
|
|
|
if(torrents_list.size() != 0){ |
|
|
|
if(!torrents_list.empty()){ |
|
|
|
QPair<QString, arborescence *> torrent = torrents_list.takeFirst(); |
|
|
|
QPair<QString, arborescence *> torrent = torrents_list.takeFirst(); |
|
|
|
mutex.unlock(); |
|
|
|
mutex.unlock(); |
|
|
|
subDeleteThread *st = new subDeleteThread(0, torrent.first, torrent.second); |
|
|
|
subDeleteThread *st = new subDeleteThread(this, torrent.first, torrent.second); |
|
|
|
subThreads << st; |
|
|
|
subThreads << st; |
|
|
|
connect(st, SIGNAL(deletionSuccessST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*))); |
|
|
|
connect(st, SIGNAL(deletionSuccessST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*))); |
|
|
|
connect(st, SIGNAL(deletionFailureST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*))); |
|
|
|
//connect(st, SIGNAL(deletionFailureST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
|
|
|
|
st->start(); |
|
|
|
st->start(); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
condition.wait(&mutex); |
|
|
|
condition.wait(&mutex); |
|
|
|