1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-14 00:37:58 +00:00

Use QPointer when interesting

This commit is contained in:
Christophe Dumez 2008-09-13 07:33:41 +00:00
parent e21c28e9d2
commit 43dcbf776b
5 changed files with 28 additions and 28 deletions

View File

@ -34,14 +34,13 @@
#include <QTcpServer>
#include <QTcpSocket>
#endif
#include <stdlib.h>
#include <QCloseEvent>
#include <QShortcut>
#include <QLabel>
#include <QModelIndex>
#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 <stdlib.h>
#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);

View File

@ -24,7 +24,7 @@
#include <QProcess>
#include <QSystemTrayIcon>
#include <QPointer>
#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<QTimer> 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> httpServer;
// Misc
#ifdef QT_4_4
QLocalServer *localServer;

View File

@ -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();

View File

@ -28,6 +28,7 @@
#include <QDateTime>
#include <QApplication>
#include <QPalette>
#include <QPointer>
#include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp>
@ -46,10 +47,10 @@ class bittorrent : public QObject {
private:
session *s;
QString scan_dir;
QTimer *timerScan;
QPointer<QTimer> timerScan;
QTimer *timerAlerts;
QTimer *fastResumeSaver;
QTimer *BigRatioTimer;
QPointer<QTimer> BigRatioTimer;
bool DHTEnabled;
downloadThread *downloader;
QString defaultSavePath;
@ -71,7 +72,7 @@ class bittorrent : public QObject {
bool UPnPEnabled;
bool NATPMPEnabled;
bool LSDEnabled;
FilterParserThread *filterParser;
QPointer<FilterParserThread> filterParser;
QString filterPath;
int folderScanInterval; // in seconds
bool queueingEnabled;

View File

@ -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<QString, arborescence *> 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);