mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 23:14:31 +00:00
Use QPointer when interesting
This commit is contained in:
parent
e21c28e9d2
commit
43dcbf776b
11
src/GUI.cpp
11
src/GUI.cpp
@ -34,14 +34,13 @@
|
|||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
#include "httpserver.h"
|
|
||||||
#include "downloadingTorrents.h"
|
#include "downloadingTorrents.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "createtorrent_imp.h"
|
#include "createtorrent_imp.h"
|
||||||
@ -56,8 +55,9 @@
|
|||||||
#include "options_imp.h"
|
#include "options_imp.h"
|
||||||
#include "previewSelect.h"
|
#include "previewSelect.h"
|
||||||
#include "allocationDlg.h"
|
#include "allocationDlg.h"
|
||||||
#include "stdlib.h"
|
#include <stdlib.h>
|
||||||
#include "console_imp.h"
|
#include "console_imp.h"
|
||||||
|
#include "httpserver.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ void GUI::acceptConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GUI::readParamsOnSocket() {
|
void GUI::readParamsOnSocket() {
|
||||||
if(clientConnection != 0) {
|
if(clientConnection) {
|
||||||
QByteArray params = clientConnection->readAll();
|
QByteArray params = clientConnection->readAll();
|
||||||
if(!params.isEmpty()) {
|
if(!params.isEmpty()) {
|
||||||
processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n")));
|
processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n")));
|
||||||
@ -1488,7 +1488,6 @@ void GUI::createSystrayDelayed() {
|
|||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
systrayIntegration = true;
|
systrayIntegration = true;
|
||||||
delete systrayCreator;
|
delete systrayCreator;
|
||||||
systrayCreator = 0;
|
|
||||||
} else {
|
} else {
|
||||||
if(timeout) {
|
if(timeout) {
|
||||||
// Retry a bit later
|
// Retry a bit later
|
||||||
@ -1498,7 +1497,6 @@ void GUI::createSystrayDelayed() {
|
|||||||
// Timed out, apparently system really does not
|
// Timed out, apparently system really does not
|
||||||
// support systray icon
|
// support systray icon
|
||||||
delete systrayCreator;
|
delete systrayCreator;
|
||||||
systrayCreator = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1562,7 +1560,6 @@ void GUI::OptionsSaved(bool deleteOptions) {
|
|||||||
else if(httpServer)
|
else if(httpServer)
|
||||||
{
|
{
|
||||||
delete httpServer;
|
delete httpServer;
|
||||||
httpServer = 0;
|
|
||||||
}
|
}
|
||||||
// Update session
|
// Update session
|
||||||
configureSession(deleteOptions);
|
configureSession(deleteOptions);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QPointer>
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
QTabWidget *tabs;
|
QTabWidget *tabs;
|
||||||
options_imp *options;
|
options_imp *options;
|
||||||
QSystemTrayIcon *myTrayIcon;
|
QSystemTrayIcon *myTrayIcon;
|
||||||
QTimer *systrayCreator;
|
QPointer<QTimer> systrayCreator;
|
||||||
QMenu *myTrayIconMenu;
|
QMenu *myTrayIconMenu;
|
||||||
DownloadingTorrents *downloadingTorrentTab;
|
DownloadingTorrents *downloadingTorrentTab;
|
||||||
FinishedTorrents *finishedTorrentTab;
|
FinishedTorrents *finishedTorrentTab;
|
||||||
@ -97,7 +97,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
// RSS
|
// RSS
|
||||||
RSSImp *rssWidget;
|
RSSImp *rssWidget;
|
||||||
// Web UI
|
// Web UI
|
||||||
HttpServer *httpServer;
|
QPointer<HttpServer> httpServer;
|
||||||
// Misc
|
// Misc
|
||||||
#ifdef QT_4_4
|
#ifdef QT_4_4
|
||||||
QLocalServer *localServer;
|
QLocalServer *localServer;
|
||||||
|
@ -97,9 +97,9 @@ bittorrent::~bittorrent() {
|
|||||||
delete deleter;
|
delete deleter;
|
||||||
delete fastResumeSaver;
|
delete fastResumeSaver;
|
||||||
delete timerAlerts;
|
delete timerAlerts;
|
||||||
if(BigRatioTimer != 0)
|
if(BigRatioTimer)
|
||||||
delete BigRatioTimer;
|
delete BigRatioTimer;
|
||||||
if(filterParser != 0)
|
if(filterParser)
|
||||||
delete filterParser;
|
delete filterParser;
|
||||||
delete downloader;
|
delete downloader;
|
||||||
if(queueingEnabled) {
|
if(queueingEnabled) {
|
||||||
@ -1558,7 +1558,7 @@ void bittorrent::disableDirectoryScanning() {
|
|||||||
timerScan->stop();
|
timerScan->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(timerScan != 0)
|
if(timerScan)
|
||||||
delete timerScan;
|
delete timerScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1618,7 +1618,6 @@ void bittorrent::setDeleteRatio(float ratio) {
|
|||||||
} else {
|
} else {
|
||||||
if(max_ratio != -1 && ratio == -1) {
|
if(max_ratio != -1 && ratio == -1) {
|
||||||
delete BigRatioTimer;
|
delete BigRatioTimer;
|
||||||
BigRatioTimer = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(max_ratio != ratio) {
|
if(max_ratio != ratio) {
|
||||||
@ -1643,7 +1642,7 @@ bool bittorrent::loadTrackerFile(QString hash) {
|
|||||||
t.tier = parts[1].toInt();
|
t.tier = parts[1].toInt();
|
||||||
trackers.push_back(t);
|
trackers.push_back(t);
|
||||||
}
|
}
|
||||||
if(trackers.size() != 0) {
|
if(!trackers.empty()) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
h.replace_trackers(trackers);
|
h.replace_trackers(trackers);
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
#include <libtorrent/ip_filter.hpp>
|
#include <libtorrent/ip_filter.hpp>
|
||||||
@ -46,10 +47,10 @@ class bittorrent : public QObject {
|
|||||||
private:
|
private:
|
||||||
session *s;
|
session *s;
|
||||||
QString scan_dir;
|
QString scan_dir;
|
||||||
QTimer *timerScan;
|
QPointer<QTimer> timerScan;
|
||||||
QTimer *timerAlerts;
|
QTimer *timerAlerts;
|
||||||
QTimer *fastResumeSaver;
|
QTimer *fastResumeSaver;
|
||||||
QTimer *BigRatioTimer;
|
QPointer<QTimer> BigRatioTimer;
|
||||||
bool DHTEnabled;
|
bool DHTEnabled;
|
||||||
downloadThread *downloader;
|
downloadThread *downloader;
|
||||||
QString defaultSavePath;
|
QString defaultSavePath;
|
||||||
@ -71,7 +72,7 @@ class bittorrent : public QObject {
|
|||||||
bool UPnPEnabled;
|
bool UPnPEnabled;
|
||||||
bool NATPMPEnabled;
|
bool NATPMPEnabled;
|
||||||
bool LSDEnabled;
|
bool LSDEnabled;
|
||||||
FilterParserThread *filterParser;
|
QPointer<FilterParserThread> filterParser;
|
||||||
QString filterPath;
|
QString filterPath;
|
||||||
int folderScanInterval; // in seconds
|
int folderScanInterval; // in seconds
|
||||||
bool queueingEnabled;
|
bool queueingEnabled;
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user