From f4be28c014e5a3bac3661415d0636872ac5c4673 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 19 Feb 2007 16:34:23 +0000 Subject: [PATCH] - Move deletion from hard drive to a thread to avoid GUI freezing --- Changelog | 1 + TODO | 1 - src/GUI.cpp | 17 ++++++++++++++--- src/GUI.h | 3 +++ src/src.pro | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 3844d6a8d..d582d14d8 100644 --- a/Changelog +++ b/Changelog @@ -14,6 +14,7 @@ - BUGFIX: Force a refresh of download list when the window is shown (avoid delay) - BUGFIX: Fixed deletion from hard drive (failed for non-empty folders) - BUGFIX: qBittorrent now identifies its version correctly on the network + - BUGFIX: Preventing GUI from freezing when deleting a download permanently - COSMETIC: Replaced OSD messages by systray messages * Tue Nov 28 2006 - Christophe Dumez - v0.8.0 diff --git a/TODO b/TODO index 0a4cfd42d..0ea7ce178 100644 --- a/TODO +++ b/TODO @@ -36,6 +36,5 @@ // In v0.9.0 - Wait for libtorrent v0.12 official release -- Move deletion from hard drive to a thread to avoid GUI freezing - Should create options dialog only when needed to save up some memory - Download from RSS feeds \ No newline at end of file diff --git a/src/GUI.cpp b/src/GUI.cpp index 78a970727..550c77b44 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -1081,10 +1081,21 @@ void GUI::deletePermanently(){ torrentBackup.remove(fileName+".incremental"); torrentBackup.remove(fileName+".pieces"); torrentBackup.remove(fileName+".savepath"); - // Remove from Hard drive TODO + // Remove from Hard drive qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); - if(!misc::removePath(savePath+QDir::separator()+fileName)){ - qDebug("Couldn't remove the download on the hard drive"); + // Deleting in a thread to avoid GUI freeze + deleteThread *deleter = new deleteThread(savePath+QDir::separator()+fileName); + deleters << deleter; + int i = 0; + while(i < deleters.size()){ + deleter = deleters.at(i); + if(deleter->isFinished()){ + qDebug("Delete thread has finished, deleting it"); + deleters.removeAt(i); + delete deleter; + }else{ + ++i; + } } // Update info bar setInfoBar("'" + fileName +"' "+tr("removed.", " removed.")); diff --git a/src/GUI.h b/src/GUI.h index 7453c6653..751c6e040 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -43,6 +43,8 @@ #include "about_imp.h" #include "previewSelect.h" #include "trackerLogin.h" +#include "deleteThread.h" + #define TIME_TRAY_BALLOON 5000 @@ -72,6 +74,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ downloadThread *downloader; downloadFromURL *downloadFromURLDialog; bool DHTEnabled; + QList deleters; // GUI related options_imp *options; createtorrent *createWindow; diff --git a/src/src.pro b/src/src.pro index 968e6cce1..6dfea24da 100644 --- a/src/src.pro +++ b/src/src.pro @@ -102,7 +102,7 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \ PropListDelegate.h previewSelect.h \ PreviewListDelegate.h trackerLogin.h \ downloadThread.h downloadFromURLImp.h \ - torrentAddition.h + torrentAddition.h deleteThread.h FORMS += MainWindow.ui options.ui about.ui \ properties.ui createtorrent.ui preview.ui \ login.ui downloadFromURL.ui addTorrentDialog.ui