2
0
forked from Ivasoft/DSView

fix: Popup a message when there is no data to export

This commit is contained in:
dreamsourcelabTAI
2024-04-10 21:00:37 +08:00
parent 058e505df7
commit f79a231de2
7 changed files with 38 additions and 1 deletions

View File

@@ -69,6 +69,7 @@ DecoderStack::DecoderStack(pv::SigSession *session,
_snapshot = NULL;
_progress = 0;
_is_decoding = false;
_result_count = 0;
_stack.push_back(new decode::Decoder(dec));
@@ -375,6 +376,7 @@ void DecoderStack::init()
_error_message = QString();
_no_memory = false;
_snapshot = NULL;
_result_count = 0;
for (auto i = _rows.begin();i != _rows.end(); i++) {
(*i).second->clear();
@@ -802,6 +804,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *self)
d->_no_memory = true;
return;
}
d->_result_count++;
// Find the row
assert(pdata->pdo);

View File

@@ -183,6 +183,10 @@ public:
bool check_required_probes();
inline uint64_t get_result_count(){
return _result_count;
}
private:
void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session);
void execute_decode_stack();
@@ -218,6 +222,7 @@ private:
bool _is_capture_end;
int _progress;
bool _is_decoding;
uint64_t _result_count;
friend class DecoderStackTest::TwoDecoderStack;
};

View File

@@ -43,6 +43,7 @@
#include "../utility/path.h"
#include "../log.h"
#include "../ui/langresource.h"
#include "../ui/msgbox.h"
#define EXPORT_DEC_ROW_COUNT_MAX 20
@@ -108,7 +109,14 @@ ProtocolExp::ProtocolExp(QWidget *parent, SigSession *session) :
}
void ProtocolExp::accept()
{
{
if (_session->have_decoded_result() == false)
{
QString errMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_DECODED_RESULT), "No data to export");
MsgBox::Show(errMsg);
return;
}
QDialog::accept();
if (_row_sel_list.empty()){

View File

@@ -2556,4 +2556,15 @@ namespace pv
}
}
bool SigSession::have_decoded_result()
{
for (auto trace : _decode_traces){
if (trace->decoder()->get_result_count() > 0){
return true;
}
}
return false;
}
} // namespace pv

View File

@@ -449,6 +449,8 @@ public:
void update_lang_text();
bool have_decoded_result();
private:
void set_cur_samplelimits(uint64_t samplelimits);
void set_cur_snap_samplerate(uint64_t samplerate);