From e10558ff5b7902bcbd4b39ffea5ddbbe399d1106 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 11 Mar 2023 13:53:05 +0100 Subject: [PATCH] bug correction: when stopping a dl an error when prompted --- mainwindow.cpp | 6 +++--- mainwindow.h | 1 + tools.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 9f5b055..a0ca699 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -983,7 +983,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) tr("Rsync process crashed")); } //test result code of command (if 20 then command stopped by user) - if (exitCode != 0) + if (exitCode != 0 and this->stopDlAsked != true) { if (exitCode == 20) { @@ -1006,7 +1006,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) retry = true; } } - + this->stopDlAsked = false; this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information); // disconnecting signals to slots @@ -1080,6 +1080,7 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item) if (reply == QMessageBox::Yes) { // stopping download + this->stopDlAsked = true; emit (stopDownloading(this->downloading.process)); } }else @@ -1096,7 +1097,6 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item) // removing line from download list ui->listDownload->removeItemWidget(item); delete item; - } } if (config.autosaveCheckbox->checkState() == Qt::Checked) diff --git a/mainwindow.h b/mainwindow.h index 6546f43..e820b03 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -120,6 +120,7 @@ class MainWindow : public QMainWindow QSystemTrayIcon * trayIcon; QString icon = "/usr/share/icons/RsyncUI.png"; bool rescan = false; + bool stopDlAsked; QList UnitText { tr("B"), diff --git a/tools.cpp b/tools.cpp index 498b10a..ad97286 100644 --- a/tools.cpp +++ b/tools.cpp @@ -48,7 +48,7 @@ const vector explode(const string& s, const char& c, int n = 0) // return true in case of error bool testRsyncReturn(MainWindow * w, QProcess * myProcess) { - if (myProcess->exitStatus() != 0) + if (myProcess->exitStatus() != 0 and w->stopDlAsked != true) { QMessageBox::warning( w, @@ -58,6 +58,7 @@ bool testRsyncReturn(MainWindow * w, QProcess * myProcess) QMessageBox::Ok); return true; } + w->stopDlAsked = false; return false; }