mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Fix possible crash on qBittorrent shutdown
This commit is contained in:
parent
0a2efaf5fc
commit
390508e7db
2 changed files with 26 additions and 18 deletions
|
@ -1534,13 +1534,15 @@ void QBtSession::saveFastResumeData() {
|
|||
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||
if(!h.is_valid() || !h.has_metadata()) continue;
|
||||
if(isQueueingEnabled())
|
||||
TorrentPersistentData::savePriority(h);
|
||||
// Actually with should save fast resume data for paused files too
|
||||
//if(h.is_paused()) continue;
|
||||
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
||||
h.save_resume_data();
|
||||
++num_resume_data;
|
||||
try {
|
||||
if(isQueueingEnabled())
|
||||
TorrentPersistentData::savePriority(h);
|
||||
// Actually with should save fast resume data for paused files too
|
||||
//if(h.is_paused()) continue;
|
||||
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
||||
h.save_resume_data();
|
||||
++num_resume_data;
|
||||
} catch(libtorrent::invalid_handle&) {}
|
||||
}
|
||||
while (num_resume_data > 0) {
|
||||
alert const* a = s->wait_for_alert(seconds(30));
|
||||
|
@ -1556,7 +1558,8 @@ void QBtSession::saveFastResumeData() {
|
|||
s->pop_alert();
|
||||
try {
|
||||
// Remove torrent from session
|
||||
s->remove_torrent(rda->handle);
|
||||
if(rda->handle.is_valid())
|
||||
s->remove_torrent(rda->handle);
|
||||
}catch(libtorrent::libtorrent_exception){}
|
||||
continue;
|
||||
}
|
||||
|
@ -1571,16 +1574,18 @@ void QBtSession::saveFastResumeData() {
|
|||
QDir torrentBackup(misc::BTBackupLocation());
|
||||
const QTorrentHandle h(rd->handle);
|
||||
if(!h.is_valid()) continue;
|
||||
// Remove old fastresume file if it exists
|
||||
const QString file = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
|
||||
if(QFile::exists(file))
|
||||
misc::safeRemove(file);
|
||||
boost::filesystem::ofstream out(boost::filesystem::path(file.toLocal8Bit().constData()), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||
// Remove torrent from session
|
||||
s->remove_torrent(rd->handle);
|
||||
s->pop_alert();
|
||||
try {
|
||||
// Remove old fastresume file if it exists
|
||||
const QString file = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
|
||||
if(QFile::exists(file))
|
||||
misc::safeRemove(file);
|
||||
boost::filesystem::ofstream out(boost::filesystem::path(file.toLocal8Bit().constData()), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||
// Remove torrent from session
|
||||
s->remove_torrent(rd->handle);
|
||||
s->pop_alert();
|
||||
} catch(libtorrent::invalid_handle&){}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ enum FilePriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7};
|
|||
enum TreeItemType {TFILE, FOLDER, ROOT};
|
||||
|
||||
class TreeItem {
|
||||
private:
|
||||
enum TreeItemColumns {COL_NAME, COL_SIZE, COL_PROGRESS, COL_PRIO};
|
||||
|
||||
private:
|
||||
QList<TreeItem*> childItems;
|
||||
QList<QVariant> itemData;
|
||||
|
|
Loading…
Reference in a new issue