diff options
author | Tim Jenssen <tim.jenssen@digia.com> | 2013-03-21 16:34:38 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@digia.com> | 2013-03-21 16:48:38 +0100 |
commit | bb5d8be66eb1ccd15b87369d9668ab342587a828 (patch) | |
tree | 34923554a130a62c41a50047c59bcbc3e521e71b /src/libs/kdtools/kdupdaterfiledownloader.cpp | |
parent | 4cde7b2ed657e5cc2f5f7c071f4ff0a7dd20d56b (diff) |
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 <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs/kdtools/kdupdaterfiledownloader.cpp')
-rw-r--r-- | src/libs/kdtools/kdupdaterfiledownloader.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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)); } } |