diff options
author | Martin Kampas <martin.kampas@jolla.com> | 2018-10-10 15:34:05 +0200 |
---|---|---|
committer | Martin Kampas <martin.kampas@jolla.com> | 2020-11-04 11:12:13 +0100 |
commit | 8f86b47e717819d1df858e14b62f1ff36616acc0 (patch) | |
tree | de549efd36f473999824b2f8c117bd83c0658808 /src | |
parent | 7c246c77bdf6a7f4d6f682128ca6cf2f702d8698 (diff) |
Fix segfault on file download error properly
The onError function destroys instances required later during the error
message construction.
This improves over the fix introduced with commit
6a93f37440a3dcc72bb5e496dac90a8f95d63eab.
Change-Id: I54c4064eb225d3e3913ce5073706a5ce5717d234
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/kdtools/filedownloader.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libs/kdtools/filedownloader.cpp b/src/libs/kdtools/filedownloader.cpp index ca50e26d9..fb3d2677e 100644 --- a/src/libs/kdtools/filedownloader.cpp +++ b/src/libs/kdtools/filedownloader.cpp @@ -812,9 +812,9 @@ void KDUpdater::LocalFileDownloader::doDownload() QString localFile = this->url().toLocalFile(); d->source = new QFile(localFile, this); if (!d->source->open(QFile::ReadOnly)) { - onError(); setDownloadAborted(tr("Cannot open file \"%1\" for reading: %2").arg(QFileInfo(localFile) - .fileName(), d->source ? d->source->errorString() : tr("File not found"))); + .fileName(), d->source->errorString())); + onError(); return; } @@ -828,9 +828,9 @@ void KDUpdater::LocalFileDownloader::doDownload() } if (!d->destination->isOpen()) { - onError(); setDownloadAborted(tr("Cannot open file \"%1\" for writing: %2") .arg(QFileInfo(d->destination->fileName()).fileName(), d->destination->errorString())); + onError(); return; } @@ -901,10 +901,10 @@ void KDUpdater::LocalFileDownloader::timerEvent(QTimerEvent *event) if (numWritten < 0) { killTimer(d->timerId); d->timerId = -1; - onError(); setDownloadAborted(tr("Writing to file \"%1\" failed: %2").arg( QDir::toNativeSeparators(d->destination->fileName()), d->destination->errorString())); + onError(); return; } toWrite -= numWritten; @@ -1089,11 +1089,11 @@ void KDUpdater::ResourceFileDownloader::timerEvent(QTimerEvent *event) { if (event->timerId() == d->timerId) { if (!d->destFile.isOpen()) { - onError(); killTimer(d->timerId); emit downloadProgress(1); setDownloadAborted(tr("Cannot read resource file \"%1\": %2").arg(downloadedFileName(), d->destFile.errorString())); + onError(); return; } |