From bb5d8be66eb1ccd15b87369d9668ab342587a828 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 21 Mar 2013 16:34:38 +0100 Subject: fix crash in HttpDownloader If the download destination can not be opened it will shutdown everything. Which deletes the destination file object. Change-Id: Id16c71bf1157aa82984a9ad8462b1b8cc92bdd24 Reviewed-by: Karsten Heimrich --- src/libs/kdtools/kdupdaterfiledownloader.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp index a026fc3c4..9ad3861dd 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp @@ -848,10 +848,11 @@ void KDUpdater::HttpDownloader::httpReadyRead() while (written < read) { const qint64 numWritten = d->destination->write(buffer.data() + written, read - written); if (numWritten < 0) { - const QString err = d->destination->errorString(); + const QString error = d->destination->errorString(); + const QString fileName = d->destination->fileName(); d->shutDown(); - setDownloadAborted(tr("Cannot download %1: Writing to temporary file failed: %2") - .arg(url().toString(), err)); + setDownloadAborted(tr("Cannot download %1: Writing to file '%2' failed: %3") + .arg(url().toString(), fileName, error)); return; } written += numWritten; @@ -977,9 +978,11 @@ void KDUpdater::HttpDownloader::startDownload(const QUrl &url) } if (!d->destination->isOpen()) { + const QString error = d->destination->errorString(); + const QString fileName = d->destination->fileName(); d->shutDown(); - setDownloadAborted(tr("Cannot download %1: Could not create temporary file: %2").arg(url.toString(), - d->destination->errorString())); + setDownloadAborted(tr("Cannot download %1: Could not create %2: %3").arg( + url.toString(), fileName, error)); } } -- cgit v1.2.3