mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 22:47:21 -06:00
- Transfer lists refreshers were moved to separate threads to improve GUI responsiveness. Please report any problem (like mutex deadlocks in console output) or crashes.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QSettings>
|
||||
#include <QStandardItemModel>
|
||||
#include <QHeaderView>
|
||||
#include <QMutexLocker>
|
||||
|
||||
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
||||
setupUi(this);
|
||||
@@ -51,6 +52,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
||||
finishedList->header()->resizeSection(0, 200);
|
||||
}
|
||||
// Make download list header clickable for sorting
|
||||
qRegisterMetaType<QModelIndex>("QModelIndex");
|
||||
finishedList->header()->setClickable(true);
|
||||
finishedList->header()->setSortIndicatorShown(true);
|
||||
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int)));
|
||||
@@ -67,12 +69,15 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
||||
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered()));
|
||||
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
|
||||
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
|
||||
refresher = new FinishedListRefresher(this);
|
||||
refresher->start();
|
||||
}
|
||||
|
||||
FinishedTorrents::~FinishedTorrents(){
|
||||
saveColWidthFinishedList();
|
||||
delete finishedListDelegate;
|
||||
delete finishedListModel;
|
||||
delete refresher;
|
||||
}
|
||||
|
||||
void FinishedTorrents::addFinishedSHA(QString hash){
|
||||
@@ -80,6 +85,7 @@ void FinishedTorrents::addFinishedSHA(QString hash){
|
||||
BTSession->setTorrentFinishedChecking(hash);
|
||||
}
|
||||
if(finishedSHAs.indexOf(hash) == -1) {
|
||||
QMutexLocker locker(&finishedListAccess);
|
||||
finishedSHAs << hash;
|
||||
int row = finishedListModel->rowCount();
|
||||
torrent_handle h = BTSession->getTorrentHandle(hash);
|
||||
@@ -168,6 +174,8 @@ void FinishedTorrents::on_actionSet_upload_limit_triggered(){
|
||||
|
||||
void FinishedTorrents::updateFinishedList(){
|
||||
// qDebug("Updating finished list");
|
||||
if(((GUI*)parent)->getCurrentTab() != 1) return;
|
||||
QMutexLocker locker(&finishedListAccess);
|
||||
QString hash;
|
||||
foreach(hash, finishedSHAs){
|
||||
torrent_handle h = BTSession->getTorrentHandle(hash);
|
||||
@@ -213,6 +221,7 @@ int FinishedTorrents::getRowFromHash(QString hash) const{
|
||||
|
||||
// Will move it to download tab
|
||||
void FinishedTorrents::deleteFromFinishedList(QString hash){
|
||||
QMutexLocker locker(&finishedListAccess);
|
||||
int row = getRowFromHash(hash);
|
||||
if(row == -1){
|
||||
std::cerr << "Error: couldn't find hash in finished list\n";
|
||||
@@ -246,6 +255,7 @@ void FinishedTorrents::showProperties(const QModelIndex &index){
|
||||
}
|
||||
|
||||
void FinishedTorrents::updateFileSize(QString hash){
|
||||
QMutexLocker locker(&finishedListAccess);
|
||||
int row = getRowFromHash(hash);
|
||||
finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)BTSession->torrentEffectiveSize(hash)));
|
||||
}
|
||||
@@ -294,6 +304,7 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
|
||||
*/
|
||||
|
||||
void FinishedTorrents::sortFinishedList(int index){
|
||||
QMutexLocker locker(&finishedListAccess);
|
||||
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
||||
if(finishedList->header()->sortIndicatorSection() == index){
|
||||
if(sortOrder == Qt::AscendingOrder){
|
||||
|
||||
Reference in New Issue
Block a user