Browse Source

Cleaned up QBtSession destructor code

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
efe5e7b068
  1. 27
      src/qtlibtorrent/qbtsession.cpp
  2. 3
      src/qtlibtorrent/qbtsession.h

27
src/qtlibtorrent/qbtsession.cpp

@ -81,7 +81,7 @@ QBtSession::QBtSession()
preAllocateAll(false), addInPause(false), ratio_limit(-1), preAllocateAll(false), addInPause(false), ratio_limit(-1),
UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false),
DHTEnabled(false), current_dht_port(0), queueingEnabled(false), DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
torrentExport(false), exiting(false) torrentExport(false)
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
, geoipDBLoaded(false), resolve_countries(false) , geoipDBLoaded(false), resolve_countries(false)
#endif #endif
@ -143,37 +143,15 @@ QBtSession::QBtSession()
qDebug("* BTSession constructed"); qDebug("* BTSession constructed");
} }
session_proxy QBtSession::asyncDeletion() {
qDebug("Bittorrent session async deletion IN");
exiting = true;
// Do some BT related saving
#if LIBTORRENT_VERSION_MINOR < 15
saveDHTEntry();
#endif
saveSessionState();
saveFastResumeData();
// Delete session
session_proxy sp = s->abort();
delete s;
qDebug("Bittorrent session async deletion OUT");
return sp;
}
// Main destructor // Main destructor
QBtSession::~QBtSession() { QBtSession::~QBtSession() {
qDebug("BTSession destructor IN"); qDebug("BTSession destructor IN");
if(!exiting) {
// Do some BT related saving // Do some BT related saving
#if LIBTORRENT_VERSION_MINOR < 15 #if LIBTORRENT_VERSION_MINOR < 15
saveDHTEntry(); saveDHTEntry();
#endif #endif
saveSessionState(); saveSessionState();
saveFastResumeData(); saveFastResumeData();
qDebug("Deleting the session");
// Delete session
session_proxy sp = s->abort();
delete s;
}
// Delete our objects // Delete our objects
if(m_tracker) if(m_tracker)
delete m_tracker; delete m_tracker;
@ -190,6 +168,9 @@ QBtSession::~QBtSession() {
delete httpServer; delete httpServer;
if(timerETA) if(timerETA)
delete timerETA; delete timerETA;
// Delete session
qDebug("Deleting the session");
delete s;
qDebug("BTSession destructor OUT"); qDebug("BTSession destructor OUT");
} }

3
src/qtlibtorrent/qbtsession.h

@ -108,7 +108,6 @@ public slots:
void downloadFromUrl(QString url); void downloadFromUrl(QString url);
void deleteTorrent(QString hash, bool delete_local_files = false); void deleteTorrent(QString hash, bool delete_local_files = false);
void startUpTorrents(); void startUpTorrents();
session_proxy asyncDeletion();
void recheckTorrent(QString hash); void recheckTorrent(QString hash);
void useAlternativeSpeedsLimit(bool alternative); void useAlternativeSpeedsLimit(bool alternative);
/* Needed by Web UI */ /* Needed by Web UI */
@ -257,8 +256,6 @@ private:
// Web UI // Web UI
QPointer<HttpServer> httpServer; QPointer<HttpServer> httpServer;
QList<QUrl> url_skippingDlg; QList<QUrl> url_skippingDlg;
// Fast exit (async)
bool exiting;
// GeoIP // GeoIP
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
bool geoipDBLoaded; bool geoipDBLoaded;

Loading…
Cancel
Save