diff --git a/src/GUI.cpp b/src/GUI.cpp index 4b02e7cb3..bda92b531 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -34,14 +34,13 @@ #include #include #endif - +#include #include #include #include #include #include "GUI.h" -#include "httpserver.h" #include "downloadingTorrents.h" #include "misc.h" #include "createtorrent_imp.h" @@ -56,8 +55,9 @@ #include "options_imp.h" #include "previewSelect.h" #include "allocationDlg.h" -#include "stdlib.h" +#include #include "console_imp.h" +#include "httpserver.h" using namespace libtorrent; @@ -472,7 +472,7 @@ void GUI::acceptConnection() { } void GUI::readParamsOnSocket() { - if(clientConnection != 0) { + if(clientConnection) { QByteArray params = clientConnection->readAll(); if(!params.isEmpty()) { processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n"))); @@ -1488,7 +1488,6 @@ void GUI::createSystrayDelayed() { createTrayIcon(); systrayIntegration = true; delete systrayCreator; - systrayCreator = 0; } else { if(timeout) { // Retry a bit later @@ -1498,7 +1497,6 @@ void GUI::createSystrayDelayed() { // Timed out, apparently system really does not // support systray icon delete systrayCreator; - systrayCreator = 0; } } } @@ -1562,7 +1560,6 @@ void GUI::OptionsSaved(bool deleteOptions) { else if(httpServer) { delete httpServer; - httpServer = 0; } // Update session configureSession(deleteOptions); diff --git a/src/GUI.h b/src/GUI.h index cd8286df8..2e214f7e3 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -24,7 +24,7 @@ #include #include - +#include #include "ui_MainWindow.h" #include "qtorrenthandle.h" @@ -66,7 +66,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ QTabWidget *tabs; options_imp *options; QSystemTrayIcon *myTrayIcon; - QTimer *systrayCreator; + QPointer systrayCreator; QMenu *myTrayIconMenu; DownloadingTorrents *downloadingTorrentTab; FinishedTorrents *finishedTorrentTab; @@ -97,7 +97,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ // RSS RSSImp *rssWidget; // Web UI - HttpServer *httpServer; + QPointer httpServer; // Misc #ifdef QT_4_4 QLocalServer *localServer; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 76981eca8..1f6f6bf52 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -97,9 +97,9 @@ bittorrent::~bittorrent() { delete deleter; delete fastResumeSaver; delete timerAlerts; - if(BigRatioTimer != 0) + if(BigRatioTimer) delete BigRatioTimer; - if(filterParser != 0) + if(filterParser) delete filterParser; delete downloader; if(queueingEnabled) { @@ -1558,7 +1558,7 @@ void bittorrent::disableDirectoryScanning() { timerScan->stop(); } } - if(timerScan != 0) + if(timerScan) delete timerScan; } @@ -1618,7 +1618,6 @@ void bittorrent::setDeleteRatio(float ratio) { } else { if(max_ratio != -1 && ratio == -1) { delete BigRatioTimer; - BigRatioTimer = 0; } } if(max_ratio != ratio) { @@ -1643,7 +1642,7 @@ bool bittorrent::loadTrackerFile(QString hash) { t.tier = parts[1].toInt(); trackers.push_back(t); } - if(trackers.size() != 0) { + if(!trackers.empty()) { QTorrentHandle h = getTorrentHandle(hash); h.replace_trackers(trackers); h.force_reannounce(); diff --git a/src/bittorrent.h b/src/bittorrent.h index fa23d6c7a..d104b3558 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -46,10 +47,10 @@ class bittorrent : public QObject { private: session *s; QString scan_dir; - QTimer *timerScan; + QPointer timerScan; QTimer *timerAlerts; QTimer *fastResumeSaver; - QTimer *BigRatioTimer; + QPointer BigRatioTimer; bool DHTEnabled; downloadThread *downloader; QString defaultSavePath; @@ -71,7 +72,7 @@ class bittorrent : public QObject { bool UPnPEnabled; bool NATPMPEnabled; bool LSDEnabled; - FilterParserThread *filterParser; + QPointer filterParser; QString filterPath; int folderScanInterval; // in seconds bool queueingEnabled; diff --git a/src/deleteThread.h b/src/deleteThread.h index 37e990082..c9bb03942 100644 --- a/src/deleteThread.h +++ b/src/deleteThread.h @@ -35,27 +35,30 @@ class subDeleteThread : public QThread { private: QString save_path; arborescence *arb; - bool abort; 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(){ - abort = true; - wait(); + qDebug("subDeleteThread successfuly deleted"); + //wait(); } signals: // For subthreads void deletionSuccessST(subDeleteThread* st); - void deletionFailureST(subDeleteThread* st); + //void deletionFailureST(subDeleteThread* st); protected: void run(){ - if(arb->removeFromFS(save_path)) + /*if(arb->removeFromFS(save_path)) emit deletionSuccessST(this); else - emit deletionFailureST(this); + emit deletionFailureST(this);*/ + arb->removeFromFS(save_path); + emit deletionSuccessST(this); delete arb; } }; @@ -99,13 +102,13 @@ class deleteThread : public QThread { if(abort) return; mutex.lock(); - if(torrents_list.size() != 0){ + if(!torrents_list.empty()){ QPair torrent = torrents_list.takeFirst(); mutex.unlock(); - subDeleteThread *st = new subDeleteThread(0, torrent.first, torrent.second); + subDeleteThread *st = new subDeleteThread(this, torrent.first, torrent.second); subThreads << st; 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(); }else{ condition.wait(&mutex);