From: Soeren Apel Date: Wed, 18 Nov 2020 18:09:41 +0000 (+0100) Subject: Prevent Qt from crashing PV by only showing the first error X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c3c07a5f4bed7fea98ad07ca1cce34c9e5409f0b;p=pulseview.git Prevent Qt from crashing PV by only showing the first error --- diff --git a/pv/dialogs/storeprogress.cpp b/pv/dialogs/storeprogress.cpp index 2bca3476..8699ccef 100644 --- a/pv/dialogs/storeprogress.cpp +++ b/pv/dialogs/storeprogress.cpp @@ -43,7 +43,8 @@ StoreProgress::StoreProgress(const QString &file_name, const Session &session, QWidget *parent) : QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent), session_(file_name.toStdString(), output_format, options, sample_range, - session) + session), + showing_error_(false) { connect(&session_, SIGNAL(progress_updated()), this, SLOT(on_progress_updated())); @@ -79,6 +80,8 @@ void StoreProgress::run() void StoreProgress::show_error() { + showing_error_ = true; + qDebug() << "Error trying to save:" << session_.error(); QMessageBox msg(parentWidget()); @@ -109,9 +112,8 @@ void StoreProgress::on_progress_updated() setMaximum(p.second); } else { const QString err = session_.error(); - if (!err.isEmpty()) + if (!err.isEmpty() && !showing_error_) show_error(); - close(); } } diff --git a/pv/dialogs/storeprogress.hpp b/pv/dialogs/storeprogress.hpp index fd355899..730a9e42 100644 --- a/pv/dialogs/storeprogress.hpp +++ b/pv/dialogs/storeprogress.hpp @@ -20,6 +20,7 @@ #ifndef PULSEVIEW_PV_DIALOGS_STOREPROGRESS_HPP #define PULSEVIEW_PV_DIALOGS_STOREPROGRESS_HPP +#include #include #include @@ -27,6 +28,7 @@ #include +using std::atomic; using std::map; using std::pair; using std::shared_ptr; @@ -63,6 +65,7 @@ private Q_SLOTS: private: pv::StoreSession session_; + atomic showing_error_; }; } // namespace dialogs