From 4ca2d060eae530f4f2b9013ce73b7cd3dfc0d525 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 18 Nov 2009 10:29:20 +0000 Subject: [PATCH] - Make everything compile back with libtorrent v0.14 - Fix crash in search engine destructor if downloads are running --- Changelog | 26 +++++++++++++------------- INSTALL | 2 +- configure | 9 +++++++-- qcm/libtorrent-rasterbar.qcm | 9 +++++++-- src/bittorrent.cpp | 9 +++++++-- src/downloadThread.cpp | 2 ++ src/qtorrenthandle.cpp | 4 ++++ src/qtorrenthandle.h | 4 ++++ src/searchEngine.cpp | 4 ++-- src/torrentAddition.h | 5 +++++ src/torrentPersistentData.h | 3 ++- 11 files changed, 54 insertions(+), 23 deletions(-) diff --git a/Changelog b/Changelog index ac8bd03b7..0c1f9f612 100644 --- a/Changelog +++ b/Changelog @@ -1,19 +1,6 @@ * Unknown - Christophe Dumez - v2.0.0 - - FEATURE: Added per-torrent super seeding mode - FEATURE: Added program option to disable splash screen - - FEATURE: Support for storing symbolic links in .torrent files - - FEATURE: Support for uTorrent interpretation of multi-tracker torrents - - FEATURE: Handle torrents with duplicate filenames - - FEATURE: Support for merkle hash tree torrents (.merkle.torrent) - - FEATURE: Metadata download from swarm is now compatible with µtorrent - - FEATURE: Support tracker exchange between peers - - FEATURE: Better http seed support - - FEATURE: Tracker connections are now also subject to IP filtering - - FEATURE: Include DHT traffic in the rate limiter - - FEATURE: Support for bitcomet padding files - - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) - FEATURE: Dropped dependency on libcurl and libzzip - - FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required) - FEATURE: Display more information regarding the torrent in its properties - FEATURE: Various optimizations to save CPU and memory - FEATURE: Folder scanning now works with CIFS and NFS mounted folders @@ -25,6 +12,19 @@ - FEATURE: New peers can manually be added to the torrents - FEATURE: Support per-peer rate limiting - FEATURE: Support peer manual ban + - FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required) + - FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only) + - FEATURE: Support for storing symbolic links in .torrent files (libtorrent >= v0.15 only) + - FEATURE: Support for uTorrent interpretation of multi-tracker torrents (libtorrent >= v0.15 only) + - FEATURE: Handle torrents with duplicate filenames (libtorrent >= v0.15 only) + - FEATURE: Support for merkle hash tree torrents (.merkle.torrent) (libtorrent >= v0.15 only) + - FEATURE: Metadata download from swarm is now compatible with µtorrent (libtorrent >= v0.15 only) + - FEATURE: Support tracker exchange between peers (libtorrent >= v0.15 only) + - FEATURE: Better http seed support (libtorrent >= v0.15 only) + - FEATURE: Tracker connections are now also subject to IP filtering (libtorrent >= v0.15 only) + - FEATURE: Include DHT traffic in the rate limiter (libtorrent >= v0.15 only) + - FEATURE: Support for bitcomet padding files (libtorrent >= v0.15 only) + - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) (libtorrent >= v0.15 only) - COSMETIC: Merged download / upload lists - COSMETIC: Torrents can be filtered based on their status - COSMETIC: Torrent properties are now displayed in main window diff --git a/INSTALL b/INSTALL index 44a899a20..c7c926321 100644 --- a/INSTALL +++ b/INSTALL @@ -10,7 +10,7 @@ will install and execute qBittorrent hopefully without any problems. Dependencies: - Qt >= 4.4.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml) -- libtorrent-rasterbar by Arvid Norberg (>= v0.15.0 REQUIRED) +- libtorrent-rasterbar by Arvid Norberg (>= 0.14.0 REQUIRED, >= v0.15.0 ADVISED) -> http://www.qbittorrent.org/download.php (advised) -> http://www.libtorrent.net Be careful: another library (the one used by rTorrent) uses a similar name. diff --git a/configure b/configure index acebb41f4..a1402fcf0 100755 --- a/configure +++ b/configure @@ -292,11 +292,12 @@ class qc_libtorrent_rasterbar : public ConfObj { public: qc_libtorrent_rasterbar(Conf *c) : ConfObj(c) {} - QString name() const { return "libtorrent-rasterbar >= 0.15.0"; } + QString name() const { return "libtorrent-rasterbar >= 0.14.0 (>= 0.15.0 advised)"; } QString shortname() const { return "libtorrent-rasterbar"; } bool exec(){ QStringList incs; - QString req_ver = "0.15.0"; + QString req_ver = "0.14.0"; + QString adv_ver = "0.15.0"; QString version, libs, other; VersionMode mode = VersionMin; if(!conf->findPkgConfig("libtorrent-rasterbar", mode, req_ver, &version, &incs, &libs, &other)) @@ -305,6 +306,10 @@ public: conf->addIncludePath(incs[n]); if(!libs.isEmpty()) conf->addLib(libs); + if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) + printf("\nWarning: libtorrent-rasterbar v%s was detected.\nAlthough it will compile and run, you will be missing some features. Please consider updating to v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); + else + conf->addDefine("LIBTORRENT_0_15"); return true; } }; diff --git a/qcm/libtorrent-rasterbar.qcm b/qcm/libtorrent-rasterbar.qcm index 5bfbba185..1512d1cca 100644 --- a/qcm/libtorrent-rasterbar.qcm +++ b/qcm/libtorrent-rasterbar.qcm @@ -8,11 +8,12 @@ class qc_libtorrent_rasterbar : public ConfObj { public: qc_libtorrent_rasterbar(Conf *c) : ConfObj(c) {} - QString name() const { return "libtorrent-rasterbar >= 0.15.0"; } + QString name() const { return "libtorrent-rasterbar >= 0.14.0 (>= 0.15.0 advised)"; } QString shortname() const { return "libtorrent-rasterbar"; } bool exec(){ QStringList incs; - QString req_ver = "0.15.0"; + QString req_ver = "0.14.0"; + QString adv_ver = "0.15.0"; QString version, libs, other; VersionMode mode = VersionMin; if(!conf->findPkgConfig("libtorrent-rasterbar", mode, req_ver, &version, &incs, &libs, &other)) @@ -21,6 +22,10 @@ public: conf->addIncludePath(incs[n]); if(!libs.isEmpty()) conf->addLib(libs); + if(!conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) + printf("\nWarning: libtorrent-rasterbar v%s was detected.\nAlthough it will compile and run, you will be missing some features. Please consider updating to v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); + else + conf->addDefine("LIBTORRENT_0_15"); return true; } }; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 3b7fb9a76..e1bc8ea4b 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -43,7 +43,9 @@ #include "geoip.h" #include "torrentPersistentData.h" #include -#include +#ifdef LIBTORRENT_0_15 + #include +#endif #include #include //#include @@ -81,7 +83,9 @@ bittorrent::bittorrent() : DHTEnabled(false), preAllocateAll(false), addInPause( // Enabling plugins //s->add_extension(&create_metadata_plugin); s->add_extension(&create_ut_metadata_plugin); +#ifdef LIBTORRENT_0_15 s->add_extension(create_lt_trackers_plugin); +#endif s->add_extension(&create_ut_pex_plugin); s->add_extension(&create_smart_ban_plugin); timerAlerts = new QTimer(); @@ -831,13 +835,14 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr p.save_path = defaultTempPath.toLocal8Bit().data(); } +#ifdef LIBTORRENT_0_15 // Skip checking and directly start seeding (new in libtorrent v0.15) if(TorrentTempData::isSeedingMode(hash)){ p.seed_mode=true; } else { p.seed_mode=false; } - +#endif // TODO: Remove in v1.6.0: For backward compatibility only if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { p.save_path = savePath.toLocal8Bit().data(); diff --git a/src/downloadThread.cpp b/src/downloadThread.cpp index 2c83dbd8a..af81ebe4a 100644 --- a/src/downloadThread.cpp +++ b/src/downloadThread.cpp @@ -43,7 +43,9 @@ downloadThread::downloadThread(QObject* parent) : QObject(parent) { } downloadThread::~downloadThread(){ + qDebug("Deleting network manager"); delete networkManager; + qDebug("Deleted network manager"); } void downloadThread::processDlFinished(QNetworkReply* reply) { diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 9ef7f8214..562bb16e1 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -179,10 +179,12 @@ QString QTorrentHandle::save_path() const { return misc::toQString(h.save_path().string()); } +#ifdef LIBTORRENT_0_15 bool QTorrentHandle::super_seeding() const { Q_ASSERT(h.is_valid()); return h.super_seeding(); } +#endif QStringList QTorrentHandle::url_seeds() const { Q_ASSERT(h.is_valid()); @@ -493,10 +495,12 @@ void QTorrentHandle::file_priority(int index, int priority) const { h.file_priority(index, priority); } +#ifdef LIBTORRENT_0_15 void QTorrentHandle::super_seeding(bool on) const { Q_ASSERT(h.is_valid()); h.super_seeding(on); } +#endif void QTorrentHandle::resolve_countries(bool r) { Q_ASSERT(h.is_valid()); diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index e3e22fd52..5ce9871dd 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -115,7 +115,9 @@ class QTorrentHandle { qlonglong seeding_time() const; std::vector file_priorities() const; bool is_sequential_download() const; + #ifdef LIBTORRENT_0_15 bool super_seeding() const; +#endif QString creation_date() const; void get_peer_info(std::vector&) const; bool resolve_countries() const; @@ -144,7 +146,9 @@ class QTorrentHandle { void auto_managed(bool) const; void force_recheck() const; void move_storage(QString path) const; + #ifdef LIBTORRENT_0_15 void super_seeding(bool on) const; +#endif void resolve_countries(bool r); void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const; void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const; diff --git a/src/searchEngine.cpp b/src/searchEngine.cpp index d97e63eab..dcbf4c728 100644 --- a/src/searchEngine.cpp +++ b/src/searchEngine.cpp @@ -108,7 +108,7 @@ SearchEngine::~SearchEngine(){ foreach(QProcess *downloader, downloaders) { downloader->kill(); downloader->waitForFinished(); - delete downloader; + //delete downloader; } delete searchTimeout; delete searchProcess; @@ -336,7 +336,7 @@ void SearchEngine::downloadFinished(int exitcode, QProcess::ExitStatus) { } } qDebug("Deleting downloadProcess"); - downloaders.removeAll(downloadProcess); + downloaders.removeOne(downloadProcess); delete downloadProcess; } diff --git a/src/torrentAddition.h b/src/torrentAddition.h index 25a9b84ba..30a1296aa 100644 --- a/src/torrentAddition.h +++ b/src/torrentAddition.h @@ -97,6 +97,9 @@ public: addInPause->setChecked(true); addInPause->setEnabled(false); } +#ifndef LIBTORRENT_0_15 + addInSeed->setEnabled(false); +#endif } ~torrentAdditionDialog() { @@ -297,6 +300,7 @@ public slots: settings.setValue(QString::fromUtf8("LastDirTorrentAdd"), savePathTxt->text()); // Create .incremental file if necessary TorrentTempData::setSequential(hash, checkIncrementalDL->isChecked()); +#ifdef LIBTORRENT_0_15 // Skip file checking and directly start seeding if(addInSeed->isChecked()) { // Check if local file(s) actually exist @@ -307,6 +311,7 @@ public slots: return; } } +#endif // Check if there is at least one selected file if(allFiltered()){ QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent")); diff --git a/src/torrentPersistentData.h b/src/torrentPersistentData.h index 7fff28f68..94be80442 100644 --- a/src/torrentPersistentData.h +++ b/src/torrentPersistentData.h @@ -99,6 +99,7 @@ public: } +#ifdef LIBTORRENT_0_15 static void setSeedingMode(QString hash,bool seed){ QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QHash all_data = settings.value("torrents-tmp", QHash()).toHash(); @@ -116,7 +117,7 @@ public: return data["seeding"].toBool(); return false; } - +#endif static QString getSavePath(QString hash) { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));