Browse Source

Fix possible crash on qBittorrent shutdown

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
390508e7db
  1. 5
      src/qtlibtorrent/qbtsession.cpp
  2. 3
      src/torrentfilesmodel.h

5
src/qtlibtorrent/qbtsession.cpp

@ -1534,6 +1534,7 @@ void QBtSession::saveFastResumeData() { @@ -1534,6 +1534,7 @@ void QBtSession::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
@ -1541,6 +1542,7 @@ void QBtSession::saveFastResumeData() { @@ -1541,6 +1542,7 @@ void QBtSession::saveFastResumeData() {
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,6 +1558,7 @@ void QBtSession::saveFastResumeData() { @@ -1556,6 +1558,7 @@ void QBtSession::saveFastResumeData() {
s->pop_alert();
try {
// Remove torrent from session
if(rda->handle.is_valid())
s->remove_torrent(rda->handle);
}catch(libtorrent::libtorrent_exception){}
continue;
@ -1571,6 +1574,7 @@ void QBtSession::saveFastResumeData() { @@ -1571,6 +1574,7 @@ void QBtSession::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))
@ -1581,6 +1585,7 @@ void QBtSession::saveFastResumeData() { @@ -1581,6 +1585,7 @@ void QBtSession::saveFastResumeData() {
// Remove torrent from session
s->remove_torrent(rd->handle);
s->pop_alert();
} catch(libtorrent::invalid_handle&){}
}
}

3
src/torrentfilesmodel.h

@ -46,6 +46,9 @@ enum FilePriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7}; @@ -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…
Cancel
Save