diff --git a/Changelog b/Changelog index 7fbebf675..620df70d9 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ * Unreleased - Christophe Dumez - v2.6.2 - BUGFIX: Do not report PeX as being disabled when DHT is + - BUGFIX: Fix possible crash on adding magnet links - I18N: Updated Greek, Croatian, Unkrainian and Bulgarian translations - I18N: Added Armenian translation - I18N: Remove country flags from program preferences (language selection) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index fd814db56..6ff9ad0fc 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1101,7 +1101,6 @@ void QBtSession::loadTorrentTempData(QTorrentHandle h, QString savePath, bool ma if(TorrentTempData::hasTempData(hash)) { // sequential download h.set_sequential_download(TorrentTempData::isSequential(hash)); - h.prioritize_first_last_piece(TorrentTempData::isSequential(hash)); // The following is useless for newly added magnet if(!magnet) { @@ -1110,6 +1109,9 @@ void QBtSession::loadTorrentTempData(QTorrentHandle h, QString savePath, bool ma TorrentTempData::getFilesPriority(hash, fp); h.prioritize_files(fp); + // Prioritize first/last piece + h.prioritize_first_last_piece(TorrentTempData::isSequential(hash)); + // Update file names const QStringList files_path = TorrentTempData::getFilesPath(hash); bool force_recheck = false; diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index 4ef956fdb..d14f27af3 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -606,10 +606,12 @@ void QTorrentHandle::prioritize_first_last_piece(int file_index, bool b) const { } void QTorrentHandle::prioritize_first_last_piece(bool b) const { + if(!torrent_handle::has_metadata()) return; // Download first and last pieces first for all media files in the torrent torrent_info::file_iterator it; int index = 0; - for(it = get_torrent_info().begin_files(); it != get_torrent_info().end_files(); it++) { + torrent_info t = get_torrent_info(); + for(it = t.begin_files(); it != t.end_files(); it++) { const QString ext = misc::toQStringU(it->path.string()).split(".").last(); if(misc::isPreviewable(ext) && torrent_handle::file_priority(index) > 0) { qDebug() << "File" << it->path.string().c_str() << "is previewable, toggle downloading of first/last pieces first";