projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added UI error handling for file loading and capturing
[pulseview.git]
/
pv
/
sigsession.cpp
diff --git
a/pv/sigsession.cpp
b/pv/sigsession.cpp
index fc26a23d784b0f5b2c11fecf993e01358f582428..8ab7dab845708a1cc1c818e549096a1807b647b3 100644
(file)
--- a/
pv/sigsession.cpp
+++ b/
pv/sigsession.cpp
@@
-27,8
+27,6
@@
#include "view/analogsignal.h"
#include "view/logicsignal.h"
#include "view/analogsignal.h"
#include "view/logicsignal.h"
-#include <QDebug>
-
#include <assert.h>
using namespace boost;
#include <assert.h>
using namespace boost;
@@
-58,11
+56,13
@@
SigSession::~SigSession()
_session = NULL;
}
_session = NULL;
}
-void SigSession::load_file(const string &name)
+void SigSession::load_file(const string &name,
+ function<void (const QString)> error_handler)
{
stop_capture();
_sampling_thread.reset(new boost::thread(
{
stop_capture();
_sampling_thread.reset(new boost::thread(
- &SigSession::load_thread_proc, this, name));
+ &SigSession::load_thread_proc, this, name,
+ error_handler));
}
SigSession::capture_state SigSession::get_capture_state() const
}
SigSession::capture_state SigSession::get_capture_state() const
@@
-72,13
+72,14
@@
SigSession::capture_state SigSession::get_capture_state() const
}
void SigSession::start_capture(struct sr_dev_inst *sdi,
}
void SigSession::start_capture(struct sr_dev_inst *sdi,
- uint64_t record_length)
+ uint64_t record_length,
+ function<void (const QString)> error_handler)
{
stop_capture();
_sampling_thread.reset(new boost::thread(
&SigSession::sample_thread_proc, this, sdi,
{
stop_capture();
_sampling_thread.reset(new boost::thread(
&SigSession::sample_thread_proc, this, sdi,
- record_length));
+ record_length
, error_handler
));
}
void SigSession::stop_capture()
}
void SigSession::stop_capture()
@@
-112,17
+113,18
@@
void SigSession::set_capture_state(capture_state state)
capture_state_changed(state);
}
capture_state_changed(state);
}
-void SigSession::load_thread_proc(const string name)
+void SigSession::load_thread_proc(const string name,
+ function<void (const QString)> error_handler)
{
if (sr_session_load(name.c_str()) != SR_OK) {
{
if (sr_session_load(name.c_str()) != SR_OK) {
-
qDebug() << "Failed to load file."
;
+
error_handler(tr("Failed to load file."))
;
return;
}
sr_session_datafeed_callback_add(data_feed_in_proc);
if (sr_session_start() != SR_OK) {
return;
}
sr_session_datafeed_callback_add(data_feed_in_proc);
if (sr_session_start() != SR_OK) {
-
qDebug() << "Failed to start session."
;
+
error_handler(tr("Failed to start session."))
;
return;
}
return;
}
@@
-135,15
+137,17
@@
void SigSession::load_thread_proc(const string name)
}
void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
}
void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
- uint64_t record_length)
+ uint64_t record_length,
+ function<void (const QString)> error_handler)
{
assert(sdi);
{
assert(sdi);
+ assert(error_handler);
sr_session_new();
sr_session_datafeed_callback_add(data_feed_in_proc);
if (sr_session_dev_add(sdi) != SR_OK) {
sr_session_new();
sr_session_datafeed_callback_add(data_feed_in_proc);
if (sr_session_dev_add(sdi) != SR_OK) {
-
qDebug() << "Failed to use device."
;
+
error_handler(tr("Failed to use device."))
;
sr_session_destroy();
return;
}
sr_session_destroy();
return;
}
@@
-151,13
+155,14
@@
void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
// Set the sample limit
if (sr_config_set(sdi, SR_CONF_LIMIT_SAMPLES,
&record_length) != SR_OK) {
// Set the sample limit
if (sr_config_set(sdi, SR_CONF_LIMIT_SAMPLES,
&record_length) != SR_OK) {
- qDebug() << "Failed to configure time-based sample limit.";
+ error_handler(tr("Failed to configure "
+ "time-based sample limit."));
sr_session_destroy();
return;
}
if (sr_session_start() != SR_OK) {
sr_session_destroy();
return;
}
if (sr_session_start() != SR_OK) {
-
qDebug() << "Failed to start session."
;
+
error_handler(tr("Failed to start session."))
;
return;
}
return;
}
@@
-172,7
+177,7
@@
void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
void SigSession::feed_in_header(const sr_dev_inst *sdi)
{
shared_ptr<view::Signal> signal;
void SigSession::feed_in_header(const sr_dev_inst *sdi)
{
shared_ptr<view::Signal> signal;
- uint64_t *sample_rate;
+ uint64_t *sample_rate
= NULL
;
unsigned int logic_probe_count = 0;
unsigned int analog_probe_count = 0;
unsigned int logic_probe_count = 0;
unsigned int analog_probe_count = 0;
@@
-195,8
+200,10
@@
void SigSession::feed_in_header(const sr_dev_inst *sdi)
// Read out the sample rate
assert(sdi->driver);
// Read out the sample rate
assert(sdi->driver);
- assert(sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
- (const void**)&sample_rate, sdi) == SR_OK);
+
+ const int ret = sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
+ (const void**)&sample_rate, sdi);
+ assert(ret == SR_OK);
// Create data containers for the coming data snapshots
{
// Create data containers for the coming data snapshots
{