From bf58555a7a03378d8b535ababfe06f450a531a80 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 29 Nov 2019 02:46:48 +0800 Subject: [PATCH] Migrate away from deprecated API --- src/base/bittorrent/session.cpp | 4 ++++ src/base/bittorrent/torrentinfo.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index de761571f..1c4e854de 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -142,8 +142,12 @@ namespace bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &queuePos, MagnetUri &magnetUri) { lt::error_code ec; +#if (LIBTORRENT_VERSION_NUM < 10200) lt::bdecode_node root; lt::bdecode(data.constData(), (data.constData() + data.size()), root, ec); +#else + const lt::bdecode_node root = lt::bdecode(data, ec); +#endif if (ec || (root.type() != lt::bdecode_node::dict_t)) return false; torrentParams = CreateTorrentParams(); diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 3ce4c9cc6..1e403b9ec 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -87,11 +87,16 @@ TorrentInfo TorrentInfo::load(const QByteArray &data, QString *error) noexcept // used in `torrent_info()` constructor const int depthLimit = 100; const int tokenLimit = 10000000; - lt::error_code ec; + lt::error_code ec; +#if (LIBTORRENT_VERSION_NUM < 10200) lt::bdecode_node node; bdecode(data.constData(), (data.constData() + data.size()), node, ec , nullptr, depthLimit, tokenLimit); +#else + const lt::bdecode_node node = lt::bdecode(data, ec + , nullptr, depthLimit, tokenLimit); +#endif if (ec) { if (error) *error = QString::fromStdString(ec.message());