- BUGFIX: Fix a possible crash when pausing then deleting a torrent quickly

This commit is contained in:
Christophe Dumez
2009-09-21 19:17:41 +00:00
parent 3e4fe1f823
commit f27b49f9a3
2 changed files with 22 additions and 15 deletions

View File

@@ -1,3 +1,6 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.5.3
- BUGFIX: Fix a possible crash when pausing then deleting a torrent quickly
* Sun Sep 20 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.2 * Sun Sep 20 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.2
- BUGFIX: Some torrents were pausing for no reason - BUGFIX: Some torrents were pausing for no reason
- I18N: Updated Korean translation - I18N: Updated Korean translation

View File

@@ -1224,7 +1224,7 @@ void bittorrent::readAlerts() {
while (a.get()) { while (a.get()) {
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) { if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if(h.is_valid()){ if(h.is_valid()) {
emit finishedTorrent(h); emit finishedTorrent(h);
QString hash = h.hash(); QString hash = h.hash();
// Remember finished state // Remember finished state
@@ -1264,16 +1264,18 @@ void bittorrent::readAlerts() {
else if (save_resume_data_alert* p = dynamic_cast<save_resume_data_alert*>(a.get())) { else if (save_resume_data_alert* p = dynamic_cast<save_resume_data_alert*>(a.get())) {
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
QString file = h.hash()+".fastresume"; if(h.is_valid()) {
// Delete old fastresume file if necessary QString file = h.hash()+".fastresume";
if(QFile::exists(file)) // Delete old fastresume file if necessary
QFile::remove(file); if(QFile::exists(file))
qDebug("Saving fastresume data in %s", file.toLocal8Bit().data()); QFile::remove(file);
if (p->resume_data) qDebug("Saving fastresume data in %s", file.toLocal8Bit().data());
{ if (p->resume_data)
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().data()) / file.toLocal8Bit().data(), std::ios_base::binary); {
out.unsetf(std::ios_base::skipws); boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().data()) / file.toLocal8Bit().data(), std::ios_base::binary);
bencode(std::ostream_iterator<char>(out), *p->resume_data); out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), *p->resume_data);
}
} }
} }
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) { else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
@@ -1290,10 +1292,12 @@ void bittorrent::readAlerts() {
} }
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) { else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
h.auto_managed(false); if(h.is_valid()) {
std::cerr << "File Error: " << p->message().c_str() << std::endl; h.auto_managed(false);
if(h.is_valid()) std::cerr << "File Error: " << p->message().c_str() << std::endl;
emit fullDiskError(h, misc::toQString(p->message())); if(h.is_valid())
emit fullDiskError(h, misc::toQString(p->message()));
}
} }
else if (dynamic_cast<listen_failed_alert*>(a.get())) { else if (dynamic_cast<listen_failed_alert*>(a.get())) {
// Level: fatal // Level: fatal