From 64bfdf930c018a5bd11efe9606c74e0e99820e6d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 23 Nov 2007 15:20:26 +0000 Subject: [PATCH] - Fixed not destructing libtorrent session bug --- src/bittorrent.cpp | 38 ++++++++++++++++++++++++++++++------- src/bittorrent.h | 3 +++ src/downloadingTorrents.cpp | 1 - 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 5d1a87355..d4706d143 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -43,7 +43,7 @@ #define MAX_TRACKER_ERRORS 2 // Main constructor -bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1) { +bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false) { // To avoid some exceptions fs::path::default_name_check(fs::no_check); // Creating bittorrent session @@ -631,25 +631,49 @@ bool bittorrent::isDHTEnabled() const{ void bittorrent::enableUPnP(bool b) { if(b) { - s->start_upnp(); + if(!UPnPEnabled) { + qDebug("Enabling UPnP"); + s->start_upnp(); + UPnPEnabled = true; + } } else { - s->stop_upnp(); + if(UPnPEnabled) { + qDebug("Disabling UPnP"); + s->stop_upnp(); + UPnPEnabled = false; + } } } void bittorrent::enableNATPMP(bool b) { if(b) { - s->start_natpmp(); + if(!NATPMPEnabled) { + qDebug("Enabling NAT-PMP"); + s->start_natpmp(); + NATPMPEnabled = true; + } } else { - s->stop_natpmp(); + if(NATPMPEnabled) { + qDebug("Disabling NAT-PMP"); + s->stop_natpmp(); + NATPMPEnabled = false; + } } } void bittorrent::enableLSD(bool b) { if(b) { - s->start_lsd(); + if(!LSDEnabled) { + qDebug("Enabling LSD"); + s->start_lsd(); + LSDEnabled = true; + } } else { - s->stop_lsd(); + if(LSDEnabled) { + qDebug("Disabling LSD"); + s->stop_lsd(); + LSDEnabled = false; + } } } diff --git a/src/bittorrent.h b/src/bittorrent.h index d534bc896..9b0060424 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -62,6 +62,9 @@ class bittorrent : public QObject{ int maxConnecsPerTorrent; int maxUploadsPerTorrent; float max_ratio; + bool UPnPEnabled; + bool NATPMPEnabled; + bool LSDEnabled; protected: QString getSavePath(QString hash); diff --git a/src/downloadingTorrents.cpp b/src/downloadingTorrents.cpp index 43a114f65..6eaca4d8a 100644 --- a/src/downloadingTorrents.cpp +++ b/src/downloadingTorrents.cpp @@ -207,7 +207,6 @@ void DownloadingTorrents::setInfoBar(QString info, QColor color) { infoBar->clear(); nbLines = 1; } - qDebug("Color is %s", color.name().toUtf8().data()); infoBar->append(QString::fromUtf8("")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8(" - ") + info + QString::fromUtf8("")); }