mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Fix possible crash on torrent removal
This commit is contained in:
@@ -1571,6 +1571,7 @@ void Bittorrent::saveFastResumeData() {
|
||||
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||
if(!h.is_valid() || !h.has_metadata()) continue;
|
||||
try {
|
||||
if(isQueueingEnabled())
|
||||
TorrentPersistentData::savePriority(h);
|
||||
// Actually with should save fast resume data for paused files too
|
||||
@@ -1578,6 +1579,7 @@ void Bittorrent::saveFastResumeData() {
|
||||
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
||||
h.save_resume_data();
|
||||
++num_resume_data;
|
||||
} catch(invalid_handle&) {}
|
||||
}
|
||||
while (num_resume_data > 0) {
|
||||
alert const* a = s->wait_for_alert(seconds(30));
|
||||
@@ -1593,8 +1595,9 @@ void Bittorrent::saveFastResumeData() {
|
||||
s->pop_alert();
|
||||
try {
|
||||
// Remove torrent from session
|
||||
if(rda->handle.is_valid())
|
||||
s->remove_torrent(rda->handle);
|
||||
}catch(libtorrent::libtorrent_exception){}
|
||||
}catch(libtorrent::libtorrent_exception&){}
|
||||
continue;
|
||||
}
|
||||
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
|
||||
@@ -1608,6 +1611,7 @@ void Bittorrent::saveFastResumeData() {
|
||||
QDir torrentBackup(misc::BTBackupLocation());
|
||||
const QTorrentHandle h(rd->handle);
|
||||
if(!h.is_valid()) continue;
|
||||
try {
|
||||
// Remove old fastresume file if it exists
|
||||
const QString file = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
|
||||
if(QFile::exists(file))
|
||||
@@ -1618,6 +1622,7 @@ void Bittorrent::saveFastResumeData() {
|
||||
// Remove torrent from session
|
||||
s->remove_torrent(rd->handle);
|
||||
s->pop_alert();
|
||||
}catch(libtorrent::libtorrent_exception&){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user