record_length, sample_rate));
}
-vector< shared_ptr<view::Signal> >& SigSession::get_signals()
+vector< shared_ptr<view::Signal> > SigSession::get_signals()
{
+ lock_guard<mutex> lock(_signals_mutex);
return _signals;
}
switch (packet->type) {
case SR_DF_HEADER:
{
- lock_guard<mutex> lock(_data_mutex);
+ lock_guard<mutex> lock(_signals_mutex);
_signals.clear();
break;
}
case SR_DF_META_LOGIC:
{
assert(packet->payload);
-
- lock_guard<mutex> lock(_data_mutex);
-
const sr_datafeed_meta_logic &meta_logic =
*(sr_datafeed_meta_logic*)packet->payload;
+ {
+ lock_guard<mutex> lock(_data_mutex);
+
// Create an empty LogiData for coming data snapshots
_logic_data.reset(new LogicData(meta_logic));
assert(_logic_data);
if(!_logic_data)
break;
+ }
+
+ {
+ lock_guard<mutex> lock(_signals_mutex);
// Add the signals
for (int i = 0; i < meta_logic.num_probes; i++)
signals_changed();
break;
}
+ }
case SR_DF_LOGIC:
{
void start_capture(struct sr_dev_inst* sdi, uint64_t record_length,
uint64_t sample_rate);
- std::vector< boost::shared_ptr<view::Signal> >&
+ std::vector< boost::shared_ptr<view::Signal> >
get_signals();
boost::shared_ptr<LogicData> get_data();
struct sr_datafeed_packet *packet);
private:
- mutable boost::mutex _data_mutex;
+ mutable boost::mutex _signals_mutex;
std::vector< boost::shared_ptr<view::Signal> > _signals;
+
+ mutable boost::mutex _data_mutex;
boost::shared_ptr<LogicData> _logic_data;
boost::shared_ptr<LogicDataSnapshot> _cur_logic_snapshot;
const QPoint &pt)
{
const int w = width();
- const vector< shared_ptr<Signal> > &sigs =
- _view.session().get_signals();
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
const int v_offset = _view.v_offset();
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
void Header::paintEvent(QPaintEvent *event)
{
const int w = width();
- const vector< shared_ptr<Signal> > &sigs =
- _view.session().get_signals();
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
{
assert(event);
- const vector< shared_ptr<Signal> > &sigs =
- _view.session().get_signals();
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
if(event->button() & Qt::LeftButton) {
_mouse_down_point = event->pos();
void View::normalize_layout()
{
- vector< shared_ptr<Signal> > &sigs = _session.get_signals();
+ const vector< shared_ptr<Signal> > sigs(_session.get_signals());
int v_min = INT_MAX;
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
void View::reset_signal_layout()
{
int offset = SignalMargin;
- vector< shared_ptr<Signal> > &sigs = _session.get_signals();
+ const vector< shared_ptr<Signal> > sigs(_session.get_signals());
BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
s->set_v_offset(offset);
offset += SignalHeight + 2 * SignalMargin;
int Viewport::get_total_height() const
{
int h = 0;
- BOOST_FOREACH(const shared_ptr<Signal> s,
- _view.session().get_signals()) {
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
+ BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
assert(s);
h = max(s->get_v_offset() + View::SignalHeight, h);
}
void Viewport::paintEvent(QPaintEvent *event)
{
- const vector< shared_ptr<Signal> > &sigs =
- _view.session().get_signals();
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);