From 2694a0947f0d07048ab054bed567e82bfe9598d4 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 4 Jan 2009 12:44:55 +0000 Subject: [PATCH] - Fixed possible crash when pausing a torrent --- src/bittorrent.cpp | 7 +++++++ src/qtorrenthandle.cpp | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 123a582d3..4829cd705 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1116,6 +1116,13 @@ void bittorrent::readAlerts() { qDebug("Received finished alert for %s", h.name().toUtf8().data()); } } + if (torrent_paused_alert* p = dynamic_cast(a.get())) { + QTorrentHandle h(p->handle); + if(h.is_valid()){ + h.save_resume_data(); + qDebug("Received paused alert for %s", h.name().toUtf8().data()); + } + } else if (save_resume_data_alert* p = dynamic_cast(a.get())) { QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QTorrentHandle h(p->handle); diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index fba68471d..b3044105c 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -319,7 +319,6 @@ void QTorrentHandle::pause() { Q_ASSERT(h.is_valid()); h.auto_managed(false); h.pause(); - h.save_resume_data(); } void QTorrentHandle::resume() {