From 54ce519978d242758c2aefa4df41f4d809425103 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 25 Mar 2024 11:12:29 +0800 Subject: [PATCH] check required channels of the decoder --- DSView/pv/data/decoderstack.cpp | 25 +++++++++++++++++-------- DSView/pv/data/decoderstack.h | 2 ++ DSView/pv/view/decodetrace.cpp | 22 ++++++++++++++++------ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index 154fec77..aa42f5c8 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -402,6 +402,17 @@ void DecoderStack::begin_decode_work() _decode_state = Stopped; } +bool DecoderStack::check_required_probes() +{ + for(auto dec : _stack){ + if (!dec->have_required_probes()) { + return false; + } + } + + return true; +} + void DecoderStack::do_decode_work() { //set the flag to exit from task thread @@ -425,14 +436,12 @@ void DecoderStack::do_decode_work() _snapshot = NULL; // Check that all decoders have the required channels - for(auto dec : _stack){ - if (!dec->have_required_probes()) { - _error_message = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DECODERSTACK_DECODE_WORK_ERROR), - "One or more required channels have not been specified"); - dsv_err("ERROR:%s", _error_message.toStdString().c_str()); - return; - } - } + if (!check_required_probes()) { + _error_message = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DECODERSTACK_DECODE_WORK_ERROR), + "One or more required channels have not been specified"); + dsv_err("ERROR:%s", _error_message.toStdString().c_str()); + return; + } // We get the logic data of the first channel in the list. // This works because we are currently assuming all diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index 310161a2..89428386 100644 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -181,6 +181,8 @@ public: return _progress; } + bool check_required_probes(); + private: void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session); void execute_decode_stack(); diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 49dddf10..351e1685 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -664,10 +664,12 @@ bool DecodeTrace::create_popup(bool isnew) { (void)isnew; - int ret = false; //setting have changed flag + int ret = false; //setting have changed flag + bool bOpenDlg = true; - while (true) + while (bOpenDlg) { + bOpenDlg = false; QWidget *top = AppControl::Instance()->GetTopWindow(); dialogs::DecoderOptionsDlg dlg(top); dlg.set_cursor_range(_decode_cursor1, _decode_cursor2); @@ -688,14 +690,22 @@ bool DecodeTrace::create_popup(bool isnew) } dlg.get_cursor_range(_decode_cursor1, _decode_cursor2); + + // Reopen the dialog to select the required probes. + if (ret && _decoder_stack->check_required_probes() == false) + { + QString errMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DECODERSTACK_DECODE_WORK_ERROR), + "One or more required channels have not been specified"); + MsgBox::Show(errMsg); + + ret = false; + bOpenDlg = true; + } } if (dlg.is_reload_form()){ ret = false; - } - - if (QDialog::Rejected == dlg_ret || dlg.is_reload_form() == false){ - break; + bOpenDlg = true; } }