diff --git a/DSView/pv/appcontrol.cpp b/DSView/pv/appcontrol.cpp index 9cf40035..6fa5f704 100644 --- a/DSView/pv/appcontrol.cpp +++ b/DSView/pv/appcontrol.cpp @@ -36,7 +36,6 @@ AppControl::AppControl() _device_manager = new pv::DeviceManager(); _session = new pv::SigSession(_device_manager); - _session->_appCntrol = this; } AppControl::AppControl(AppControl &o) diff --git a/DSView/pv/data/analog.cpp b/DSView/pv/data/analog.cpp index 6685e453..85046322 100755 --- a/DSView/pv/data/analog.cpp +++ b/DSView/pv/data/analog.cpp @@ -22,8 +22,7 @@ #include "analog.h" #include "analogsnapshot.h" - -#include + using namespace boost; using namespace std; @@ -49,13 +48,13 @@ deque< boost::shared_ptr >& Analog::get_snapshots() void Analog::clear() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->clear(); } void Analog::init() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->init(); } diff --git a/DSView/pv/data/analogsnapshot.cpp b/DSView/pv/data/analogsnapshot.cpp index 77b2e4bf..7da95a1a 100755 --- a/DSView/pv/data/analogsnapshot.cpp +++ b/DSView/pv/data/analogsnapshot.cpp @@ -28,12 +28,9 @@ #include #include - -#include - + #include "analogsnapshot.h" -using namespace boost; using namespace std; namespace pv { @@ -60,7 +57,7 @@ AnalogSnapshot::~AnalogSnapshot() void AnalogSnapshot::free_envelop() { for (unsigned int i = 0; i < _channel_num; i++) { - BOOST_FOREACH(Envelope &e, _envelope_levels[i]) { + for(auto &e : _envelope_levels[i]) { if (e.samples) free(e.samples); } @@ -70,7 +67,12 @@ void AnalogSnapshot::free_envelop() void AnalogSnapshot::init() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); + init_all(); +} + +void AnalogSnapshot::init_all() +{ _sample_count = 0; _ring_sample_count = 0; _memory_failed = false; @@ -88,10 +90,10 @@ void AnalogSnapshot::init() void AnalogSnapshot::clear() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); free_data(); free_envelop(); - init(); + init_all(); } void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, GSList *channels) @@ -167,7 +169,7 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to void AnalogSnapshot::append_payload( const sr_datafeed_analog &analog) { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); append_data(analog.data, analog.num_samples, analog.unit_pitch); // Generate the first mip-map from the data diff --git a/DSView/pv/data/analogsnapshot.h b/DSView/pv/data/analogsnapshot.h index 644dbfaa..0d6c1473 100755 --- a/DSView/pv/data/analogsnapshot.h +++ b/DSView/pv/data/analogsnapshot.h @@ -79,6 +79,9 @@ private: static const uint64_t LeafBlockSamples = 1 << LeafBlockPower; static const uint64_t LeafMask = ~(~0ULL << LeafBlockPower); +private: + void init_all(); + public: AnalogSnapshot(); diff --git a/DSView/pv/data/decode/annotation.h b/DSView/pv/data/decode/annotation.h index d45d0e5b..46d3e2eb 100755 --- a/DSView/pv/data/decode/annotation.h +++ b/DSView/pv/data/decode/annotation.h @@ -25,6 +25,7 @@ #include #include +#include class AnnotationResTable; class DecoderStatus; @@ -35,6 +36,7 @@ namespace pv { namespace data { namespace decode { +//create at DecoderStack.annotation_callback class Annotation { public: diff --git a/DSView/pv/data/decode/row.cpp b/DSView/pv/data/decode/row.cpp index 99958900..63fef7c3 100755 --- a/DSView/pv/data/decode/row.cpp +++ b/DSView/pv/data/decode/row.cpp @@ -38,22 +38,7 @@ Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row, cons _row(row), _order(order) { -} - -Row::~Row() -{ - -} - -const srd_decoder* Row::decoder() const -{ - return _decoder; -} - -const srd_decoder_annotation_row* Row::row() const -{ - return _row; -} +} const QString Row::title() const { diff --git a/DSView/pv/data/decode/row.h b/DSView/pv/data/decode/row.h index d6fa4ac6..b21f8093 100755 --- a/DSView/pv/data/decode/row.h +++ b/DSView/pv/data/decode/row.h @@ -32,6 +32,7 @@ namespace pv { namespace data { namespace decode { +//map find key data class Row { public: @@ -41,12 +42,15 @@ public: const srd_decoder_annotation_row *row = NULL, const int order = -1); -public: - - ~Row(); +public: - const srd_decoder* decoder() const; - const srd_decoder_annotation_row* row() const; + inline const srd_decoder* decoder() const{ + return _decoder; + } + + inline const srd_decoder_annotation_row* row() const{ + return _row; + } const QString title() const; diff --git a/DSView/pv/data/decode/rowdata.cpp b/DSView/pv/data/decode/rowdata.cpp index c80cbfbd..9ac049e9 100755 --- a/DSView/pv/data/decode/rowdata.cpp +++ b/DSView/pv/data/decode/rowdata.cpp @@ -31,10 +31,13 @@ namespace pv { namespace data { namespace decode { +std::mutex RowData::_global_visitor_mutex; + RowData::RowData() : _max_annotation(0), _min_annotation(UINT64_MAX) { + _item_count = 0; } RowData::~RowData() @@ -44,14 +47,23 @@ RowData::~RowData() void RowData::clear() { + std::lock_guard lock(_global_visitor_mutex); + + //destroy objercts + for (Annotation *p : _annotations){ + delete p; + } _annotations.clear(); + _item_count = 0; } uint64_t RowData::get_max_sample() const { + std::lock_guard lock(_global_visitor_mutex); + if (_annotations.empty()) return 0; - return _annotations.back().end_sample(); + return _annotations.back()->end_sample(); } uint64_t RowData::get_max_annotation() const @@ -67,52 +79,64 @@ uint64_t RowData::get_min_annotation() const return _min_annotation; } -void RowData::get_annotation_subset( - vector &dest, - uint64_t start_sample, uint64_t end_sample) const -{ - for (vector::const_iterator i = _annotations.begin(); - i != _annotations.end(); i++) - if ((*i).end_sample() > start_sample && - (*i).start_sample() <= end_sample) - dest.push_back(*i); +void RowData::get_annotation_subset(std::vector &dest, + uint64_t start_sample, uint64_t end_sample) const +{ + std::lock_guard lock(_global_visitor_mutex); + + for (Annotation *p : _annotations){ + if (p->end_sample() > start_sample && + p->start_sample() <= end_sample){ + Annotation a = *p; + dest.push_back(a); + } + } } uint64_t RowData::get_annotation_index(uint64_t start_sample) const { + std::lock_guard lock(_global_visitor_mutex); uint64_t index = 0; - for (vector::const_iterator i = _annotations.begin(); - i != _annotations.end(); i++) { - if ((*i).start_sample() > start_sample) - break; - index++; - } + + for (Annotation *p : _annotations){ + if (p->start_sample() > start_sample) + break; + index++; + } + return index; } -bool RowData::push_annotation(const Annotation &a) +bool RowData::push_annotation(Annotation *a) { + if (a == NULL){ + return false; + } + + std::lock_guard lock(_global_visitor_mutex); + try { _annotations.push_back(a); - _max_annotation = max(_max_annotation, a.end_sample() - a.start_sample()); - if (a.end_sample() != a.start_sample()) - _min_annotation = min(_min_annotation, a.end_sample() - a.start_sample()); + _item_count = _annotations.size(); + _max_annotation = max(_max_annotation, a->end_sample() - a->start_sample()); + + if (a->end_sample() != a->start_sample()) + _min_annotation = min(_min_annotation, a->end_sample() - a->start_sample()); + return true; + } catch (const std::bad_alloc&) { return false; } } + -uint64_t RowData::get_annotation_size() const +bool RowData::get_annotation(Annotation &ann, uint64_t index) const { - return _annotations.size(); -} + std::lock_guard lock(_global_visitor_mutex); -bool RowData::get_annotation(Annotation &ann, - uint64_t index) const -{ if (index < _annotations.size()) { - ann = _annotations[index]; + ann = *_annotations[index]; return true; } else { return false; diff --git a/DSView/pv/data/decode/rowdata.h b/DSView/pv/data/decode/rowdata.h index 72d33456..0059567f 100755 --- a/DSView/pv/data/decode/rowdata.h +++ b/DSView/pv/data/decode/rowdata.h @@ -22,7 +22,8 @@ #ifndef DSVIEW_PV_DATA_DECODE_ROWDATA_H #define DSVIEW_PV_DATA_DECODE_ROWDATA_H -#include +#include +#include #include "annotation.h" @@ -35,33 +36,37 @@ class RowData public: RowData(); ~RowData(); + public: uint64_t get_max_sample() const; uint64_t get_max_annotation() const; - uint64_t get_min_annotation() const; - /** - * Extracts sorted annotations between two period into a vector. - */ - void get_annotation_subset( - std::vector &dest, - uint64_t start_sample, uint64_t end_sample) const; + uint64_t get_min_annotation() const; uint64_t get_annotation_index(uint64_t start_sample) const; - bool push_annotation(const Annotation &a); + bool push_annotation(Annotation *a); - uint64_t get_annotation_size() const; + inline uint64_t get_annotation_size() const{ + return _item_count; + } - bool get_annotation(pv::data::decode::Annotation &ann, - uint64_t index) const; + bool get_annotation(pv::data::decode::Annotation &ann, uint64_t index) const; + + /** + * Extracts sorted annotations between two period into a vector. + */ + void get_annotation_subset(std::vector &dest, + uint64_t start_sample, uint64_t end_sample) const; void clear(); private: - uint64_t _max_annotation; - uint64_t _min_annotation; - std::vector _annotations; + uint64_t _max_annotation; + uint64_t _min_annotation; + uint64_t _item_count; + std::vector _annotations; + static std::mutex _global_visitor_mutex; }; } diff --git a/DSView/pv/data/decodermodel.cpp b/DSView/pv/data/decodermodel.cpp index 614f67ff..c42bab6a 100755 --- a/DSView/pv/data/decodermodel.cpp +++ b/DSView/pv/data/decodermodel.cpp @@ -19,13 +19,9 @@ */ #include - -#include -#include - -#include -#include - + +#include "decode/annotation.h" +#include "decode/rowdata.h" #include "decoderstack.h" #include "decodermodel.h" diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index c9bbd504..72d094ce 100755 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -18,9 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include -#include + #include #include @@ -29,12 +27,15 @@ #include "decoderstack.h" -#include -#include -#include -#include -#include -#include +#include "logic.h" +#include "logicsnapshot.h" +#include "decode/decoder.h" +#include "decode/annotation.h" +#include "decode/rowdata.h" +#include "../sigsession.h" +#include "../view/logicsignal.h" +#include "../dsvdef.h" + using namespace boost; using namespace std; @@ -50,19 +51,23 @@ const int64_t DecoderStack::DecodeChunkLength = 4 * 1024; //const int64_t DecoderStack::DecodeChunkLength = 1024 * 1024; const unsigned int DecoderStack::DecodeNotifyPeriod = 1024; -boost::mutex DecoderStack::_global_decode_mutex; +std::mutex DecoderStack::_global_decode_mutex; DecoderStack::DecoderStack(pv::SigSession *session, const srd_decoder *const dec, DecoderStatus *decoder_status) : - _session(session), - _sample_count(0), - _frame_complete(false), - _samples_decoded(0), - _decode_state(Stopped), - _options_changed(false), - _no_memory(false), - _mark_index(-1) + _session(session) { + _samples_decoded = 0; + _sample_count = 0; + _frame_complete = false; + _decode_state = Stopped; + _options_changed = false; + _no_memory = false; + _mark_index = -1; + _decoder_status = decoder_status; + _bThreadStop = false; + _decode_thread = NULL; + connect(_session, SIGNAL(frame_began()), this, SLOT(on_new_frame())); connect(_session, SIGNAL(data_received()), @@ -72,32 +77,26 @@ DecoderStack::DecoderStack(pv::SigSession *session, _stack.push_back(boost::shared_ptr( new decode::Decoder(dec))); - - _decoder_status = decoder_status; - + build_row(); } DecoderStack::~DecoderStack() -{ -// if (_decode_thread.joinable()) { -// _decode_thread.interrupt(); -// _decode_thread.join(); -// } +{ stop_decode(); - _stack.clear(); + + for (auto &kv : _rows) + { + delete kv.second; + } _rows.clear(); + + _stack.clear(); _rows_gshow.clear(); _rows_lshow.clear(); _class_rows.clear(); } - -const std::list< boost::shared_ptr >& -DecoderStack::stack() const -{ - return _stack; -} - + void DecoderStack::push(boost::shared_ptr decoder) { assert(decoder); @@ -124,9 +123,15 @@ void DecoderStack::remove(boost::shared_ptr &decoder) void DecoderStack::build_row() { + //destory data + for (auto &kv : _rows) + { + delete kv.second; + } _rows.clear(); + // Add classes - BOOST_FOREACH (const boost::shared_ptr &dec, _stack) + for (auto &dec : _stack) { assert(dec); const srd_decoder *const decc = dec->decoder(); @@ -135,7 +140,7 @@ void DecoderStack::build_row() // Add a row for the decoder if it doesn't have a row list if (!decc->annotation_rows) { const Row row(decc); - _rows[row] = decode::RowData(); + _rows[row] = new decode::RowData(); std::map::const_iterator iter = _rows_gshow.find(row); if (iter == _rows_gshow.end()) { _rows_gshow[row] = true; @@ -159,7 +164,7 @@ void DecoderStack::build_row() const Row row(decc, ann_row, order); // Add a new empty row data object - _rows[row] = decode::RowData(); + _rows[row] = new decode::RowData(); std::map::const_iterator iter = _rows_gshow.find(row); if (iter == _rows_gshow.end()) { _rows_gshow[row] = true; @@ -184,7 +189,7 @@ void DecoderStack::build_row() int64_t DecoderStack::samples_decoded() const { - boost::lock_guard decode_lock(_output_mutex); + std::lock_guard decode_lock(_output_mutex); return _samples_decoded; } @@ -192,51 +197,39 @@ void DecoderStack::get_annotation_subset( std::vector &dest, const Row &row, uint64_t start_sample, uint64_t end_sample) const -{ - //lock_guard lock(_output_mutex); - - std::map::const_iterator iter = - _rows.find(row); +{ + auto iter = _rows.find(row); if (iter != _rows.end()) - (*iter).second.get_annotation_subset(dest, + (*iter).second->get_annotation_subset(dest, start_sample, end_sample); } uint64_t DecoderStack::get_annotation_index( const Row &row, uint64_t start_sample) const -{ - //lock_guard lock(_output_mutex); - +{ uint64_t index = 0; - std::map::const_iterator iter = - _rows.find(row); + auto iter = _rows.find(row); if (iter != _rows.end()) - index = (*iter).second.get_annotation_index(start_sample); + index = (*iter).second->get_annotation_index(start_sample); return index; } uint64_t DecoderStack::get_max_annotation(const Row &row) -{ - //lock_guard lock(_output_mutex); - - std::map::const_iterator iter = - _rows.find(row); +{ + auto iter = _rows.find(row); if (iter != _rows.end()) - return (*iter).second.get_max_annotation(); + return (*iter).second->get_max_annotation(); return 0; } uint64_t DecoderStack::get_min_annotation(const Row &row) -{ - //lock_guard lock(_output_mutex); - - std::map::const_iterator iter = - _rows.find(row); +{ + auto iter = _rows.find(row); if (iter != _rows.end()) - return (*iter).second.get_min_annotation(); + return (*iter).second->get_min_annotation(); return 0; } @@ -278,13 +271,11 @@ void DecoderStack::set_rows_lshow(const decode::Row row, bool show) } bool DecoderStack::has_annotations(const Row &row) const -{ - //lock_guard lock(_output_mutex); - - std::map::const_iterator iter = +{ + auto iter = _rows.find(row); if (iter != _rows.end()) - if(0 == (*iter).second.get_max_sample()) + if(0 == (*iter).second->get_max_sample()) return false; else return true; @@ -294,29 +285,27 @@ bool DecoderStack::has_annotations(const Row &row) const uint64_t DecoderStack::list_annotation_size() const { - boost::lock_guard lock(_output_mutex); + std::lock_guard lock(_output_mutex); uint64_t max_annotation_size = 0; - for (map::const_iterator i = _rows.begin(); + for (auto i = _rows.begin(); i != _rows.end(); i++) { map::const_iterator iter = _rows_lshow.find((*i).first); if (iter != _rows_lshow.end() && (*iter).second) max_annotation_size = max(max_annotation_size, - (*i).second.get_annotation_size()); + (*i).second->get_annotation_size()); } return max_annotation_size; } uint64_t DecoderStack::list_annotation_size(uint16_t row_index) const -{ - //lock_guard lock(_output_mutex); - //int row = 0; - for (map::const_iterator i = _rows.begin(); +{ + for (auto i = _rows.begin(); i != _rows.end(); i++) { map::const_iterator iter = _rows_lshow.find((*i).first); if (iter != _rows_lshow.end() && (*iter).second) if (row_index-- == 0) { - return (*i).second.get_annotation_size(); + return (*i).second->get_annotation_size(); } } return 0; @@ -324,14 +313,13 @@ uint64_t DecoderStack::list_annotation_size(uint16_t row_index) const bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann, uint16_t row_index, uint64_t col_index) const -{ - //lock_guard lock(_output_mutex); - for (map::const_iterator i = _rows.begin(); +{ + for (auto i = _rows.begin(); i != _rows.end(); i++) { map::const_iterator iter = _rows_lshow.find((*i).first); if (iter != _rows_lshow.end() && (*iter).second) { if (row_index-- == 0) { - return (*i).second.get_annotation(ann, col_index); + return (*i).second->get_annotation(ann, col_index); } } } @@ -341,9 +329,8 @@ bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann, bool DecoderStack::list_row_title(int row, QString &title) const -{ - //lock_guard lock(_output_mutex); - for (map::const_iterator i = _rows.begin(); +{ + for (auto i = _rows.begin(); i != _rows.end(); i++) { map::const_iterator iter = _rows_lshow.find((*i).first); if (iter != _rows_lshow.end() && (*iter).second) { @@ -357,8 +344,7 @@ bool DecoderStack::list_row_title(int row, QString &title) const } QString DecoderStack::error_message() -{ - //lock_guard lock(_output_mutex); +{ return _error_message; } @@ -374,24 +360,26 @@ void DecoderStack::init() _samples_decoded = 0; _error_message = QString(); _no_memory = false; - for (map::iterator i = _rows.begin(); - i != _rows.end(); i++) { - //_rows[(*i).first] = decode::RowData(); - (*i).second.clear(); + + for (auto i = _rows.begin(); + i != _rows.end(); i++) { + (*i).second->clear(); } + set_mark_index(-1); } void DecoderStack::stop_decode() -{ - //_snapshot.reset(); - if(_decode_state != Stopped) { - if (_decode_thread.get()) { - _decode_thread->interrupt(); - _decode_thread->join(); - _decode_state = Stopped; - } - _decode_thread.reset(); +{ + _bThreadStop = true; + + if (_decode_thread && _decode_thread->joinable()) { + _decode_thread->join(); + } + DESTROY_OBJECT(_decode_thread); + + if(_decode_state != Stopped) { + _decode_state = Stopped; } } @@ -407,7 +395,7 @@ void DecoderStack::begin_decode() init(); // Check that all decoders have the required channels - BOOST_FOREACH(const boost::shared_ptr &dec, _stack) + for(auto &dec : _stack) if (!dec->have_required_probes()) { _error_message = tr("One or more required channels " "have not been specified"); @@ -417,9 +405,9 @@ void DecoderStack::begin_decode() // We get the logic data of the first channel in the list. // This works because we are currently assuming all // LogicSignals have the same data/snapshot - BOOST_FOREACH (const boost::shared_ptr &dec, _stack) { + for (auto &dec : _stack) { if (dec && !dec->channels().empty()) { - BOOST_FOREACH(boost::shared_ptr sig, _session->get_signals()) { + for(auto &sig : _session->get_signals()) { if((sig->get_index() == (*dec->channels().begin()).second) && (logic_signal = dynamic_pointer_cast(sig)) && (data = logic_signal->logic_data())) @@ -447,18 +435,23 @@ void DecoderStack::begin_decode() if (_samplerate == 0.0) return; - //_decode_thread = boost::thread(&DecoderStack::decode_proc, this); - _decode_thread.reset(new boost::thread(&DecoderStack::decode_proc, this)); + if (_decode_thread && _decode_thread->joinable()) { + _bThreadStop = true; + _decode_thread->join(); + } + DESTROY_OBJECT(_decode_thread); + + _bThreadStop = false; //reset stop flag + _decode_thread = new std::thread(&DecoderStack::decode_proc, this); } uint64_t DecoderStack::get_max_sample_count() const { uint64_t max_sample_count = 0; - for (map::const_iterator i = _rows.begin(); - i != _rows.end(); i++) - max_sample_count = max(max_sample_count, - (*i).second.get_max_sample()); + for (auto i = _rows.begin(); i != _rows.end(); i++){ + max_sample_count = max(max_sample_count, (*i).second->get_max_sample()); + } return max_sample_count; } @@ -485,13 +478,13 @@ void DecoderStack::decode_data( uint64_t entry_cnt = 0; uint64_t i = decode_start; char *error = NULL; - while(!boost::this_thread::interruption_requested() && - i < decode_end && !_no_memory) - { - //lock_guard decode_lock(_global_decode_mutex); + + while(!_bThreadStop && i < decode_end && !_no_memory) + { std::vector chunk; std::vector chunk_const; uint64_t chunk_end = decode_end; + for (int j =0 ; j < logic_di->dec_num_channels; j++) { int sig_index = logic_di->dec_channelmap[j]; if (sig_index == -1) { @@ -520,7 +513,7 @@ void DecoderStack::decode_data( i = chunk_end; { - boost::lock_guard lock(_output_mutex); + std::lock_guard lock(_output_mutex); _samples_decoded = i - decode_start + 1; } @@ -536,8 +529,12 @@ void DecoderStack::decode_data( } void DecoderStack::decode_proc() -{ - boost::lock_guard decode_lock(_global_decode_mutex); +{ + std::lock_guard decode_lock(_global_decode_mutex); + + if (_bThreadStop){ + return; + } optional sample_count; srd_session *session; @@ -554,13 +551,10 @@ void DecoderStack::decode_proc() _decode_state = Running; // Get the intial sample count - { - //unique_lock input_lock(_input_mutex); - sample_count = _sample_count = _snapshot->get_sample_count(); - } + sample_count = _sample_count = _snapshot->get_sample_count(); // Create the decoders - BOOST_FOREACH(const boost::shared_ptr &dec, _stack) + for(auto &dec : _stack) { srd_decoder_inst *const di = dec->create_decoder_inst(session); @@ -588,6 +582,7 @@ void DecoderStack::decode_proc() char *error = NULL; if (srd_session_start(session, &error) == SRD_OK) + //need a lot time decode_data(decode_start, decode_end, session); else _error_message = QString::fromLocal8Bit(error); @@ -622,14 +617,16 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) DecoderStack *const d = (DecoderStack*)decoder; assert(d); - - //lock_guard lock(d->_output_mutex); - + if (d->_no_memory) { return; } - const Annotation a(pdata, d->_decoder_status); + Annotation *a = new Annotation(pdata, d->_decoder_status); + if (a == NULL){ + d->_no_memory = true; + return; + } // Find the row assert(pdata->pdo); @@ -637,11 +634,11 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) const srd_decoder *const decc = pdata->pdo->di->decoder; assert(decc); - map::iterator row_iter = d->_rows.end(); + auto row_iter = d->_rows.end(); // Try looking up the sub-row of this class const map, Row>::const_iterator r = - d->_class_rows.find(make_pair(decc, a.format())); + d->_class_rows.find(make_pair(decc, a->format())); if (r != d->_class_rows.end()) row_iter = d->_rows.find((*r).second); else @@ -653,14 +650,13 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) assert(row_iter != d->_rows.end()); if (row_iter == d->_rows.end()) { qDebug() << "Unexpected annotation: decoder = " << decc << - ", format = " << a.format(); + ", format = " << a->format(); assert(0); return; } - // Add the annotation - boost::lock_guard lock(d->_output_mutex); - if (!(*row_iter).second.push_annotation(a)) + // Add the annotation + if (!(*row_iter).second->push_annotation(a)) d->_no_memory = true; } @@ -670,33 +666,19 @@ void DecoderStack::on_new_frame() } void DecoderStack::on_data_received() -{ -// { -// unique_lock lock(_input_mutex); -// if (_snapshot) -// _sample_count = _snapshot->get_sample_count(); -// } -// _input_cond.notify_one(); +{ } void DecoderStack::on_frame_ended() -{ -// { -// unique_lock lock(_input_mutex); -// if (_snapshot) -// _frame_complete = true; -// } -// _input_cond.notify_one(); +{ _options_changed = true; begin_decode(); } int DecoderStack::list_rows_size() -{ - //lock_guard lock(_output_mutex); +{ int rows_size = 0; - for (map::const_iterator i = _rows.begin(); - i != _rows.end(); i++) { + for (auto i = _rows.begin(); i != _rows.end(); i++) { map::const_iterator iter = _rows_lshow.find((*i).first); if (iter != _rows_lshow.end() && (*iter).second) rows_size++; diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index bc05fa6b..d7f89bf1 100755 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -27,13 +27,14 @@ #include #include -#include + #include #include +#include +#include -#include "../data/decode/row.h" -#include "../data/decode/rowdata.h" +#include "decode/row.h" #include "../data/signaldata.h" class DecoderStatus; @@ -57,6 +58,7 @@ class LogicSnapshot; namespace decode { class Annotation; class Decoder; +class RowData; } class Logic; @@ -86,9 +88,14 @@ public: virtual ~DecoderStack(); - const std::list< boost::shared_ptr >& stack() const; + inline std::list< boost::shared_ptr >& stack(){ + return _stack; + } + void push(boost::shared_ptr decoder); + void remove(boost::shared_ptr& decoder); + void build_row(); int64_t samples_decoded() const; @@ -153,8 +160,7 @@ private: void decode_proc(); - static void annotation_callback(srd_proto_data *pdata, - void *decoder); + static void annotation_callback(srd_proto_data *pdata, void *decoder); private slots: void on_new_frame(); @@ -167,45 +173,39 @@ signals: void new_decode_data(); void decode_done(); -private: - pv::SigSession *_session; +private: + std::list< boost::shared_ptr > _stack; + + boost::shared_ptr _snapshot; + + std::map _rows; + std::map _rows_gshow; + std::map _rows_lshow; + std::map, decode::Row> _class_rows; + + SigSession *_session; + decode_state _decode_state; + bool _options_changed; + bool _no_memory; + int64_t _mark_index; + DecoderStatus *_decoder_status; + QString _error_message; + int64_t _samples_decoded; + uint64_t _sample_count; + bool _frame_complete; + volatile bool _bThreadStop; + + + std::thread *_decode_thread; + mutable std::mutex _output_mutex; /** * This mutex prevents more than one decode operation occuring * concurrently. * @todo A proper solution should be implemented to allow multiple * decode operations. - */ - static boost::mutex _global_decode_mutex; - - std::list< boost::shared_ptr > _stack; - - boost::shared_ptr _snapshot; - - //mutable boost::mutex _input_mutex; - //mutable boost::condition_variable _input_cond; - uint64_t _sample_count; - bool _frame_complete; - - mutable boost::recursive_mutex _output_mutex; - //mutable boost::mutex _output_mutex; - int64_t _samples_decoded; - - std::map _rows; - std::map _rows_gshow; - std::map _rows_lshow; - std::map, decode::Row> _class_rows; - - QString _error_message; - - std::unique_ptr _decode_thread; - decode_state _decode_state; - - bool _options_changed; - bool _no_memory; - - int64_t _mark_index; - DecoderStatus *_decoder_status; + */ + static std::mutex _global_decode_mutex; friend class DecoderStackTest::TwoDecoderStack; }; diff --git a/DSView/pv/data/dso.cpp b/DSView/pv/data/dso.cpp index 7362010f..b88e77d7 100755 --- a/DSView/pv/data/dso.cpp +++ b/DSView/pv/data/dso.cpp @@ -21,8 +21,7 @@ #include "dso.h" #include "dsosnapshot.h" - -#include + using namespace boost; using namespace std; @@ -48,14 +47,14 @@ deque< boost::shared_ptr >& Dso::get_snapshots() void Dso::clear() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->clear(); } void Dso::init() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->init(); } diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index 89da7800..60a98a8c 100755 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -27,12 +27,9 @@ #include #include - -#include - + #include "dsosnapshot.h" -using namespace boost; using namespace std; namespace pv { @@ -63,7 +60,7 @@ DsoSnapshot::~DsoSnapshot() void DsoSnapshot::free_envelop() { for (unsigned int i = 0; i < _channel_num; i++) { - BOOST_FOREACH(Envelope &e, _envelope_levels[i]) { + for(auto &e : _envelope_levels[i]) { if (e.samples) free(e.samples); } @@ -73,13 +70,19 @@ void DsoSnapshot::free_envelop() void DsoSnapshot::init() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); + init_all(); +} + +void DsoSnapshot::init_all() +{ _sample_count = 0; _ring_sample_count = 0; _memory_failed = false; _last_ended = true; _envelope_done = false; _ch_enable.clear(); + for (unsigned int i = 0; i < _channel_num; i++) { for (unsigned int level = 0; level < ScaleStepCount; level++) { _envelope_levels[i][level].length = 0; @@ -90,10 +93,10 @@ void DsoSnapshot::init() void DsoSnapshot::clear() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); free_data(); free_envelop(); - init(); + init_all(); } void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count, @@ -157,7 +160,7 @@ void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sampl void DsoSnapshot::append_payload(const sr_datafeed_dso &dso) { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); if (_channel_num > 0 && dso.num_samples != 0) { append_data(dso.data, dso.num_samples, _instant); @@ -184,16 +187,16 @@ void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant) void DsoSnapshot::enable_envelope(bool enable) { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); if (!_envelope_done && enable) append_payload_to_envelope_levels(true); _envelope_en = enable; } const uint8_t *DsoSnapshot::get_samples( - int64_t start_sample, int64_t end_sample, uint16_t index) const + int64_t start_sample, int64_t end_sample, uint16_t index) { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); (void)end_sample; assert(start_sample >= 0); @@ -202,10 +205,7 @@ const uint8_t *DsoSnapshot::get_samples( assert(end_sample < (int64_t)get_sample_count()); assert(start_sample <= end_sample); -// uint16_t *const data = new uint16_t[end_sample - start_sample]; -// memcpy(data, (uint16_t*)_data + start_sample, sizeof(uint16_t) * -// (end_sample - start_sample)); -// return data; + return (uint8_t*)_data + start_sample * _channel_num + index * (_channel_num != 1); } diff --git a/DSView/pv/data/dsosnapshot.h b/DSView/pv/data/dsosnapshot.h index aa19cca5..f9586efe 100755 --- a/DSView/pv/data/dsosnapshot.h +++ b/DSView/pv/data/dsosnapshot.h @@ -25,6 +25,7 @@ #include #include +#include #include #include "snapshot.h" @@ -74,6 +75,9 @@ private: static const int VrmsScaleFactor; +private: + void init_all(); + public: DsoSnapshot(); @@ -88,7 +92,7 @@ public: void append_payload(const sr_datafeed_dso &dso); const uint8_t* get_samples(int64_t start_sample, - int64_t end_sample, uint16_t index) const; + int64_t end_sample, uint16_t index); void get_envelope_section(EnvelopeSection &s, uint64_t start, uint64_t end, float min_length, int probe_index) const; diff --git a/DSView/pv/data/group.cpp b/DSView/pv/data/group.cpp index a9ee2cbe..41329f82 100755 --- a/DSView/pv/data/group.cpp +++ b/DSView/pv/data/group.cpp @@ -21,8 +21,7 @@ #include "group.h" #include "groupsnapshot.h" - -#include + using namespace boost; using namespace std; @@ -47,13 +46,13 @@ deque< boost::shared_ptr >& Group::get_snapshots() void Group::clear() { - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->clear(); } void Group::init() { - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->init(); } diff --git a/DSView/pv/data/groupsnapshot.cpp b/DSView/pv/data/groupsnapshot.cpp index ae6b6cb3..3c5f25ee 100755 --- a/DSView/pv/data/groupsnapshot.cpp +++ b/DSView/pv/data/groupsnapshot.cpp @@ -27,8 +27,7 @@ #include #include - -#include + #include "logicsnapshot.h" #include "groupsnapshot.h" @@ -53,7 +52,7 @@ GroupSnapshot::GroupSnapshot(const boost::shared_ptr &_logic_snap { assert(_logic_snapshot); - //boost::lock_guard lock(_mutex); + memset(_envelope_levels, 0, sizeof(_envelope_levels)); _data = _logic_snapshot->get_data(); _sample_count = _logic_snapshot->get_sample_count(); @@ -94,9 +93,8 @@ GroupSnapshot::GroupSnapshot(const boost::shared_ptr &_logic_snap } GroupSnapshot::~GroupSnapshot() -{ - //boost::lock_guard lock(_mutex); - BOOST_FOREACH(Envelope &e, _envelope_levels) +{ + for(auto &e : _envelope_levels) free(e.samples); } @@ -111,16 +109,13 @@ void GroupSnapshot::clear() } uint64_t GroupSnapshot::get_sample_count() const -{ - //boost::lock_guard lock(_mutex); +{ return _sample_count; } void GroupSnapshot::append_payload() { - //boost::lock_guard lock(_mutex); - - // Generate the first mip-map from the data + append_payload_to_envelope_levels(); } @@ -134,13 +129,10 @@ const uint16_t* GroupSnapshot::get_samples( assert(start_sample <= end_sample); int64_t i; - uint16_t tmpl, tmpr; - //boost::lock_guard lock(_mutex); + uint16_t tmpl, tmpr; uint16_t *const data = new uint16_t[end_sample - start_sample]; -// memcpy(data, (uint16_t*)_data + start_sample, sizeof(uint16_t) * -// (end_sample - start_sample)); -// memset(data, 0, sizeof(uint16_t) * (end_sample - start_sample)); + for(i = start_sample; i < end_sample; i++) { if (_unit_size == 2) tmpl = *((uint16_t*)_data + i) & _mask; @@ -163,8 +155,7 @@ void GroupSnapshot::get_envelope_section(EnvelopeSection &s, assert(end <= _sample_count); assert(start <= end); assert(min_length > 0); - - //boost::lock_guard lock(_mutex); + const unsigned int min_level = max((int)floorf(logf(min_length) / LogEnvelopeScaleFactor) - 1, 0); diff --git a/DSView/pv/data/groupsnapshot.h b/DSView/pv/data/groupsnapshot.h index 4d87b001..fbd7095e 100755 --- a/DSView/pv/data/groupsnapshot.h +++ b/DSView/pv/data/groupsnapshot.h @@ -23,7 +23,7 @@ #ifndef DSVIEW_PV_DATA_GROUPSNAPSHOT_H #define DSVIEW_PV_DATA_GROUPSNAPSHOT_H -#include + #include #include "../view/signal.h" @@ -99,7 +99,7 @@ private: private: struct Envelope _envelope_levels[ScaleStepCount]; - //mutable boost::recursive_mutex _mutex; + const void *_data; uint64_t _sample_count; int _unit_size; diff --git a/DSView/pv/data/logic.cpp b/DSView/pv/data/logic.cpp index 9797b214..d2597125 100755 --- a/DSView/pv/data/logic.cpp +++ b/DSView/pv/data/logic.cpp @@ -22,9 +22,7 @@ #include "logic.h" #include "logicsnapshot.h" - -#include - + using namespace boost; using namespace std; @@ -50,14 +48,14 @@ deque< boost::shared_ptr >& Logic::get_snapshots() void Logic::clear() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->clear(); } void Logic::init() { //_snapshots.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _snapshots) + for(auto &s : _snapshots) s->init(); } diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 2dd3027e..025422ba 100755 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -28,12 +28,9 @@ #include #include #include - -#include - + #include "logicsnapshot.h" -using namespace boost; using namespace std; namespace pv { @@ -80,8 +77,13 @@ void LogicSnapshot::free_data() void LogicSnapshot::init() { - boost::lock_guard lock(_mutex); - _sample_count = 0; + std::lock_guard lock(_mutex); + init_all(); +} + +void LogicSnapshot::init_all() +{ + _sample_count = 0; _ring_sample_count = 0; _block_num = 0; _byte_fraction = 0; @@ -95,9 +97,9 @@ void LogicSnapshot::init() void LogicSnapshot::clear() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); free_data(); - init(); + init_all(); } void LogicSnapshot::capture_ended() @@ -203,7 +205,7 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total void LogicSnapshot::append_payload( const sr_datafeed_logic &logic) { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); if (logic.format == LA_CROSS_DATA) append_cross_payload(logic); diff --git a/DSView/pv/data/logicsnapshot.h b/DSView/pv/data/logicsnapshot.h index bfbf0b78..34bcc13c 100755 --- a/DSView/pv/data/logicsnapshot.h +++ b/DSView/pv/data/logicsnapshot.h @@ -32,6 +32,7 @@ #include #include +#include namespace LogicSnapshotTest { class Pow2; @@ -76,13 +77,19 @@ private: public: typedef std::pair EdgePair; +private: + void init_all(); + public: LogicSnapshot(); virtual ~LogicSnapshot(); + void free_data(); + void clear(); - void init(); + + void init(); void first_payload(const sr_datafeed_logic &logic, uint64_t total_sample_count, GSList *channels); diff --git a/DSView/pv/data/mathstack.cpp b/DSView/pv/data/mathstack.cpp index 072d0dfe..e584d392 100755 --- a/DSView/pv/data/mathstack.cpp +++ b/DSView/pv/data/mathstack.cpp @@ -19,10 +19,7 @@ */ #include "mathstack.h" - -#include -#include - + #include #include #include @@ -100,7 +97,7 @@ MathStack::~MathStack() void MathStack::free_envelop() { - BOOST_FOREACH(Envelope &e, _envelope_level) { + for(auto &e : _envelope_level) { if (e.samples) free(e.samples); } @@ -109,12 +106,12 @@ void MathStack::free_envelop() void MathStack::clear() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); } void MathStack::init() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); _sample_num = 0; _envelope_done = false; @@ -315,7 +312,7 @@ void MathStack::get_math_envelope_section(EnvelopeSection &s, void MathStack::calc_math() { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); _math_state = Running; diff --git a/DSView/pv/data/mathstack.h b/DSView/pv/data/mathstack.h index 7f6f9844..e0c1a97c 100755 --- a/DSView/pv/data/mathstack.h +++ b/DSView/pv/data/mathstack.h @@ -27,7 +27,7 @@ #include #include -#include + #include #include diff --git a/DSView/pv/data/signaldata.h b/DSView/pv/data/signaldata.h index 76f9588a..f3269421 100755 --- a/DSView/pv/data/signaldata.h +++ b/DSView/pv/data/signaldata.h @@ -25,7 +25,7 @@ #define DSVIEW_PV_DATA_SIGNALDATA_H #include -#include +#include namespace pv { namespace data { @@ -45,7 +45,7 @@ public: virtual void init() = 0; protected: - mutable boost::recursive_mutex _mutex; + mutable std::mutex _mutex; double _samplerate; }; diff --git a/DSView/pv/data/snapshot.cpp b/DSView/pv/data/snapshot.cpp index 50a094d0..2e50fc2c 100755 --- a/DSView/pv/data/snapshot.cpp +++ b/DSView/pv/data/snapshot.cpp @@ -28,9 +28,7 @@ #include #include #include - -using namespace boost; - + namespace pv { namespace data { @@ -91,13 +89,13 @@ void Snapshot::set_last_ended(bool ended) uint64_t Snapshot::get_sample_count() const { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); return _sample_count; } uint64_t Snapshot::get_ring_start() const { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); if (_sample_count < _total_sample_count) return 0; else @@ -106,7 +104,7 @@ uint64_t Snapshot::get_ring_start() const uint64_t Snapshot::get_ring_end() const { - boost::lock_guard lock(_mutex); + std::lock_guard lock(_mutex); if (_sample_count == 0) return 0; else if (_ring_sample_count == 0) diff --git a/DSView/pv/data/snapshot.h b/DSView/pv/data/snapshot.h index 5ea70a9a..e8a43588 100755 --- a/DSView/pv/data/snapshot.h +++ b/DSView/pv/data/snapshot.h @@ -23,7 +23,8 @@ #ifndef DSVIEW_PV_DATA_SNAPSHOT_H #define DSVIEW_PV_DATA_SNAPSHOT_H -#include +#include +#include namespace pv { namespace data { @@ -64,11 +65,11 @@ protected: virtual void free_data(); protected: - mutable boost::recursive_mutex _mutex; + mutable std::mutex _mutex; //std::vector _data; void* _data; - std::vector _ch_index; + mutable std::vector _ch_index; uint64_t _capacity; unsigned int _channel_num; diff --git a/DSView/pv/data/spectrumstack.cpp b/DSView/pv/data/spectrumstack.cpp index b54bddff..7a96f308 100755 --- a/DSView/pv/data/spectrumstack.cpp +++ b/DSView/pv/data/spectrumstack.cpp @@ -19,10 +19,7 @@ */ #include "spectrumstack.h" - -#include -#include - + #include #include #include @@ -173,7 +170,8 @@ void SpectrumStack::calc_fft() // Get the dso data boost::shared_ptr data; boost::shared_ptr dsoSig; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_index() == _index && dsoSig->enabled()) { data = dsoSig->dso_data(); diff --git a/DSView/pv/data/spectrumstack.h b/DSView/pv/data/spectrumstack.h index 82440595..aff91060 100755 --- a/DSView/pv/data/spectrumstack.h +++ b/DSView/pv/data/spectrumstack.h @@ -27,8 +27,7 @@ #include #include -#include - + #include #include diff --git a/DSView/pv/device/sessionfile.cpp b/DSView/pv/device/sessionfile.cpp index 2ce80e7e..7f879565 100755 --- a/DSView/pv/device/sessionfile.cpp +++ b/DSView/pv/device/sessionfile.cpp @@ -59,10 +59,9 @@ void SessionFile::use(SigSession *owner) void SessionFile::release() { - if (!_owner) + if (!_owner || !_sdi) return; - assert(_sdi); File::release(); sr_dev_close(_sdi); sr_dev_clear(_sdi->driver); diff --git a/DSView/pv/devicemanager.cpp b/DSView/pv/devicemanager.cpp index 488d3e61..51a4a128 100755 --- a/DSView/pv/devicemanager.cpp +++ b/DSView/pv/devicemanager.cpp @@ -90,11 +90,11 @@ void DeviceManager::del_device(DevInst *device) } } -std::list& DeviceManager::driver_scan( - struct sr_dev_driver *const driver, GSList *const drvopts) -{ - list driver_devices; - +void DeviceManager::driver_scan( + std::list &driver_devices, + struct sr_dev_driver *const driver, + GSList *const drvopts) +{ assert(driver); // Remove any device instances from this driver from the device @@ -118,7 +118,7 @@ std::list& DeviceManager::driver_scan( if (strncmp(driver->name, "virtual", 7)) { QDir dir(DS_RES_PATH); if (!dir.exists()) - return driver_devices; + return; } // Do the scan @@ -133,8 +133,6 @@ std::list& DeviceManager::driver_scan( // append the scanned devices to the main list _devices.insert(_devices.end(), driver_devices.begin(), driver_devices.end()); - - return driver_devices; } void DeviceManager::init_drivers() @@ -167,8 +165,10 @@ void DeviceManager::scan_all_drivers() { // Scan all drivers for all devices. struct sr_dev_driver **const drivers = sr_driver_list(); - for (struct sr_dev_driver **driver = drivers; *driver; driver++) - driver_scan(*driver); + for (struct sr_dev_driver **driver = drivers; *driver; driver++){ + std::list driver_devices; + driver_scan(driver_devices, *driver); + } } void DeviceManager::release_driver(struct sr_dev_driver *const driver) diff --git a/DSView/pv/devicemanager.h b/DSView/pv/devicemanager.h index b275b69b..4862a455 100755 --- a/DSView/pv/devicemanager.h +++ b/DSView/pv/devicemanager.h @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include @@ -69,7 +68,10 @@ public: void add_device(DevInst *device); void del_device(DevInst *device); - std::list& driver_scan(struct sr_dev_driver *const driver, GSList *const drvopts = NULL); + void driver_scan( + std::list &driver_devices, + struct sr_dev_driver *const driver=NULL, + GSList *const drvopts=NULL); void initAll(struct sr_context *sr_ctx); diff --git a/DSView/pv/dialogs/calibration.cpp b/DSView/pv/dialogs/calibration.cpp index 2a5b0a8a..7bc0771a 100755 --- a/DSView/pv/dialogs/calibration.cpp +++ b/DSView/pv/dialogs/calibration.cpp @@ -20,9 +20,7 @@ */ #include "calibration.h" - -#include - + #include #include #include diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index bfa6fe25..d8a4b392 100755 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -21,9 +21,7 @@ */ #include "deviceoptions.h" - -#include - + #include #include #include @@ -94,7 +92,7 @@ void DeviceOptions::accept() // Commit the properties const vector< boost::shared_ptr > &dev_props = _device_options_binding.properties(); - BOOST_FOREACH(boost::shared_ptr p, dev_props) { + for(auto &p : dev_props) { assert(p); p->commit(); } @@ -120,7 +118,7 @@ void DeviceOptions::accept() while(i != _probe_options_binding_list.end()) { const vector< boost::shared_ptr > &probe_props = (*i)->properties(); - BOOST_FOREACH(boost::shared_ptr p, probe_props) { + for(auto &p :probe_props) { assert(p); p->commit(); } @@ -153,7 +151,7 @@ QGridLayout * DeviceOptions::get_property_form(QWidget * parent) const vector< boost::shared_ptr > &properties = _device_options_binding.properties(); int i = 0; - BOOST_FOREACH(boost::shared_ptr p, properties) + for(auto &p : properties) { assert(p); const QString label = p->labeled_widget() ? QString() : p->label(); @@ -527,7 +525,8 @@ void DeviceOptions::analog_probes(QGridLayout &layout) const vector< boost::shared_ptr > &properties = probe_options_binding->properties(); int i = 1; - BOOST_FOREACH(boost::shared_ptr p, properties) + + for(auto &p : properties) { assert(p); const QString label = p->labeled_widget() ? QString() : p->label(); diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/pv/dialogs/dsomeasure.cpp index c5f97510..46ef2896 100755 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/pv/dialogs/dsomeasure.cpp @@ -29,8 +29,7 @@ #include #include #include - -#include + #include "../dsvdef.h" using namespace boost; @@ -57,7 +56,7 @@ DsoMeasure::DsoMeasure(SigSession *session, View &parent, _measure_tab->setTabPosition(QTabWidget::West); _measure_tab->setUsesScrollButtons(false); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s)) && dsoSig->enabled()) { QWidget *measure_widget = new QWidget(this); @@ -158,7 +157,8 @@ void DsoMeasure::accept() if(sc != NULL) { QVariant id = sc->property("id"); enum DSO_MEASURE_TYPE ms_type = DSO_MEASURE_TYPE(id.toInt()); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (_measure_tab->currentWidget()->property("index").toInt() == dsoSig->get_index()) { diff --git a/DSView/pv/dialogs/fftoptions.cpp b/DSView/pv/dialogs/fftoptions.cpp index 5af442e7..fe53c54f 100755 --- a/DSView/pv/dialogs/fftoptions.cpp +++ b/DSView/pv/dialogs/fftoptions.cpp @@ -21,8 +21,7 @@ #include "fftoptions.h" -#include - + #include #include @@ -67,7 +66,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) : _dbv_combobox = new QComboBox(this); // setup _ch_combobox - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { _ch_combobox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index())); @@ -87,7 +86,8 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) : std::vector length; std::vector view_modes; std::vector dbv_ranges; - BOOST_FOREACH(const boost::shared_ptr t, _session->get_spectrum_traces()) { + + for(auto &t : _session->get_spectrum_traces()) { boost::shared_ptr spectrumTraces; if ((spectrumTraces = dynamic_pointer_cast(t))) { windows = spectrumTraces->get_spectrum_stack()->get_windows_support(); @@ -137,7 +137,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) : } // load current settings - BOOST_FOREACH(const boost::shared_ptr t, _session->get_spectrum_traces()) { + for(auto &t : _session->get_spectrum_traces()) { boost::shared_ptr spectrumTraces; if ((spectrumTraces = dynamic_pointer_cast(t))) { if (spectrumTraces->enabled()) { @@ -230,7 +230,7 @@ void FftOptions::accept() QDialog::accept(); - BOOST_FOREACH(const boost::shared_ptr t, _session->get_spectrum_traces()) { + for(auto &t : _session->get_spectrum_traces()) { boost::shared_ptr spectrumTraces; if ((spectrumTraces = dynamic_pointer_cast(t))) { spectrumTraces->set_enable(false); diff --git a/DSView/pv/dialogs/lissajousoptions.cpp b/DSView/pv/dialogs/lissajousoptions.cpp index aa5d53f1..589ec4d4 100755 --- a/DSView/pv/dialogs/lissajousoptions.cpp +++ b/DSView/pv/dialogs/lissajousoptions.cpp @@ -31,9 +31,7 @@ #include #include -#include - - + using namespace boost; using namespace std; using namespace pv::view; @@ -74,7 +72,8 @@ LissajousOptions::LissajousOptions(SigSession *session, QWidget *parent) : _y_group = new QGroupBox(this); QHBoxLayout *xlayout = new QHBoxLayout(); QHBoxLayout *ylayout = new QHBoxLayout(); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { QString index_str = QString::number(dsoSig->get_index()); @@ -182,7 +181,7 @@ void LissajousOptions::accept() bool enable = (xindex != -1 && yindex != -1 && _enable->isChecked()); _session->lissajous_rebuild(enable, xindex, yindex, _percent->value()); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { dsoSig->set_show(!enable); diff --git a/DSView/pv/dialogs/mathoptions.cpp b/DSView/pv/dialogs/mathoptions.cpp index 95111fa5..d7c9e4bb 100755 --- a/DSView/pv/dialogs/mathoptions.cpp +++ b/DSView/pv/dialogs/mathoptions.cpp @@ -31,8 +31,7 @@ #include #include #include - -#include + using namespace boost; using namespace std; @@ -78,7 +77,8 @@ MathOptions::MathOptions(SigSession *session, QWidget *parent) : _src2_group = new QGroupBox(this); QHBoxLayout *src1_layout = new QHBoxLayout(); QHBoxLayout *src2_layout = new QHBoxLayout(); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { QString index_str = QString::number(dsoSig->get_index()); @@ -206,7 +206,8 @@ void MathOptions::accept() bool enable = (src1 != -1 && src2 != -1 && _enable->isChecked()); boost::shared_ptr dsoSig1; boost::shared_ptr dsoSig2; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_index() == src1) diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index d526a998..f594c6a9 100755 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -20,9 +20,7 @@ */ #include "protocolexp.h" - -#include - + #include #include #include @@ -192,7 +190,7 @@ void ProtocolExp::accept() decoder_stack->get_annotation_subset(annotations, row, 0, decoder_stack->sample_count()-1); if (!annotations.empty()) { - BOOST_FOREACH(const Annotation &a, annotations) { + for(auto &a : annotations) { out << QString("%1,%2,%3\n") .arg(QString::number(exported)) .arg(QString::number(a.start_sample()*ns_per_sample, 'f', 20)) diff --git a/DSView/pv/dialogs/protocollist.cpp b/DSView/pv/dialogs/protocollist.cpp index 3b2599af..53b46b30 100755 --- a/DSView/pv/dialogs/protocollist.cpp +++ b/DSView/pv/dialogs/protocollist.cpp @@ -20,8 +20,7 @@ */ #include "protocollist.h" - -#include + #include #include @@ -60,7 +59,8 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); int index = 0; - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { _protocol_combobox->addItem(d->get_name()); if (decoder_model->getDecoderStack() == d->decoder()) _protocol_combobox->setCurrentIndex(index); @@ -130,7 +130,8 @@ void ProtocolList::set_protocol(int index) const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); int cur_index = 0; - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { if (index == cur_index) { decoder_stack = d->decoder(); break; @@ -172,7 +173,8 @@ void ProtocolList::on_row_check(bool show) const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); int cur_index = 0; - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { if (cur_index == _protocol_combobox->currentIndex()) { decoder_stack = d->decoder(); break; diff --git a/DSView/pv/dialogs/regionoptions.cpp b/DSView/pv/dialogs/regionoptions.cpp index 12853c1d..62ff127a 100755 --- a/DSView/pv/dialogs/regionoptions.cpp +++ b/DSView/pv/dialogs/regionoptions.cpp @@ -20,9 +20,7 @@ */ #include "regionoptions.h" - -#include - + #include "../sigsession.h" #include "../view/cursor.h" #include "../view/view.h" diff --git a/DSView/pv/dialogs/search.cpp b/DSView/pv/dialogs/search.cpp index 74568d7f..26744536 100755 --- a/DSView/pv/dialogs/search.cpp +++ b/DSView/pv/dialogs/search.cpp @@ -24,8 +24,7 @@ #include #include - -#include + namespace pv { namespace dialogs { @@ -50,8 +49,8 @@ Search::Search(QWidget *parent, SigSession *session, std::map search_layout->setVerticalSpacing(0); int index = 0; - BOOST_FOREACH(const boost::shared_ptr sig, - _session->get_signals()) { + + for(auto &sig : _session->get_signals()) { assert(sig); boost::shared_ptr logic_sig; if ((logic_sig = boost::dynamic_pointer_cast(sig))) { @@ -111,8 +110,7 @@ std::map Search::get_pattern() std::map pattern; int index = 0; - BOOST_FOREACH(const boost::shared_ptr sig, - _session->get_signals()) { + for(auto &sig :_session->get_signals()) { assert(sig); boost::shared_ptr logic_sig; if ((logic_sig = boost::dynamic_pointer_cast(sig))) { diff --git a/DSView/pv/dialogs/waitingdialog.cpp b/DSView/pv/dialogs/waitingdialog.cpp index 6272227c..b206912b 100755 --- a/DSView/pv/dialogs/waitingdialog.cpp +++ b/DSView/pv/dialogs/waitingdialog.cpp @@ -20,8 +20,7 @@ */ #include "waitingdialog.h" - -#include + #include #include @@ -186,12 +185,13 @@ void WaitingDialog::changeText() g_variant_unref(gvar); if (zero_fgain) { boost::shared_ptr dsoSig; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) + + for(auto &s : _session->get_signals()) { if ((dsoSig = dynamic_pointer_cast(s))) dsoSig->set_enable(dsoSig->get_index() == 0); } - boost::this_thread::sleep(boost::posix_time::millisec(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); _dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_COMB, g_variant_new_boolean(true)); } } diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/pv/dock/dsotriggerdock.cpp index d11e961c..c859f824 100755 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/pv/dock/dsotriggerdock.cpp @@ -26,7 +26,7 @@ #include "../view/dsosignal.h" #include -#include + #include #include @@ -387,7 +387,8 @@ void DsoTriggerDock::init() // setup _channel_comboBox disconnect(_channel_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(channel_changed(int))); _channel_comboBox->clear(); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { _channel_comboBox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index())); diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index 48e04900..a35374ab 100755 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -45,7 +45,7 @@ #include #include -#include + #include #include #include "../ui/msgbox.h" @@ -377,7 +377,7 @@ void ProtocolDock::decoded_progress(int progress) _session->get_decode_signals()); int index = 0; - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + for(auto &d : decode_sigs) { pg = d->get_progress(); if (d->decoder()->out_of_memory()) err = tr("(Out of Memory)"); @@ -416,7 +416,8 @@ void ProtocolDock::set_model() // clear mark_index of all DecoderStacks const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { d->decoder()->set_mark_index(-1); } } @@ -432,7 +433,7 @@ void ProtocolDock::update_model() decoder_model->setDecoderStack(decode_sigs.at(0)->decoder()); else { unsigned int index = 0; - BOOST_FOREACH(const boost::shared_ptr d, decode_sigs) { + for(auto &d : decode_sigs) { if (d->decoder() == decoder_model->getDecoderStack()) { decoder_model->setDecoderStack(d->decoder()); break; @@ -473,9 +474,11 @@ void ProtocolDock::item_clicked(const QModelIndex &index) if (decoder_stack->list_annotation(ann, index.column(), index.row())) { const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { d->decoder()->set_mark_index(-1); } + decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2); _session->show_region(ann.start_sample(), ann.end_sample(), false); } @@ -566,7 +569,8 @@ void ProtocolDock::nav_table_view() decoder_stack->list_annotation(ann, index.column(), index.row()); const std::vector< boost::shared_ptr > decode_sigs( _session->get_decode_signals()); - BOOST_FOREACH(boost::shared_ptr d, decode_sigs) { + + for(auto &d : decode_sigs) { d->decoder()->set_mark_index(-1); } decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2); diff --git a/DSView/pv/dock/protocoldock.h b/DSView/pv/dock/protocoldock.h index 1e7e9ded..b300846a 100755 --- a/DSView/pv/dock/protocoldock.h +++ b/DSView/pv/dock/protocoldock.h @@ -38,10 +38,12 @@ #include #include -#include +#include #include "../data/decodermodel.h" #include "protocolitemlayer.h" + + namespace pv { class SigSession; @@ -140,7 +142,7 @@ private: QPushButton *_dn_nav_button; QPushButton *_search_button; - mutable boost::mutex _search_mutex; + mutable std::mutex _search_mutex; bool _search_edited; bool _searching; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 7cadf548..dd0372af 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -27,7 +27,6 @@ #include -#include #include #include @@ -520,8 +519,12 @@ void MainWindow::device_attach() DeviceManager &_device_manager = _control->GetDeviceManager(); for (driver = drivers; *driver; driver++) - if (*driver) - _device_manager.driver_scan(*driver); + { + if (*driver){ + std::list driver_devices; + _device_manager.driver_scan(driver_devices, *driver); + } + } _session->set_default_device(boost::bind(&MainWindow::session_error, this, @@ -581,9 +584,12 @@ void MainWindow::device_detach_post() _hot_detach = false; struct sr_dev_driver **const drivers = sr_driver_list(); struct sr_dev_driver **driver; - for (driver = drivers; *driver; driver++) - if (*driver) - _device_manager.driver_scan(*driver); + for (driver = drivers; *driver; driver++){ + if (*driver){ + std::list driver_devices; + _device_manager.driver_scan(driver_devices, *driver); + } + } _session->set_default_device(boost::bind(&MainWindow::session_error, this, QString(tr("Set Default Device failed")), _1)); @@ -821,7 +827,7 @@ void MainWindow::commit_trigger(bool instant) if (!_trigger_widget->commit_trigger()) { /* simple trigger check trigger_enable */ - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) + for(auto &s : _session->get_signals()) { assert(s); boost::shared_ptr logicSig; @@ -843,7 +849,7 @@ void MainWindow::commit_trigger(bool instant) msg.exec(); if (msg.mBox()->clickedButton() == cancelButton) { - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) + for(auto &s : _session->get_signals()) { assert(s); boost::shared_ptr logicSig; @@ -1055,7 +1061,7 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev) // load signal setting if (file_dev && (sdi->mode == DSO)) { - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { foreach (const QJsonValue &value, sessionObj["channel"].toArray()) { QJsonObject obj = value.toObject(); if ((strcmp(s->get_name().toStdString().c_str(), g_strdup(obj["name"].toString().toStdString().c_str())) == 0) && @@ -1074,7 +1080,7 @@ bool MainWindow::load_session_json(QJsonDocument json, bool file_dev) } } } else { - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { foreach (const QJsonValue &value, sessionObj["channel"].toArray()) { QJsonObject obj = value.toObject(); if ((s->get_index() == obj["index"].toDouble()) && @@ -1183,7 +1189,7 @@ bool MainWindow::on_store_session(QString name) } } - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { QJsonObject s_obj; s_obj["index"] = s->get_index(); s_obj["type"] = s->get_type(); @@ -1328,7 +1334,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) _view->zoom(-1); break; case Qt::Key_0: - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto & s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_index() == 0) @@ -1341,7 +1347,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) update(); break; case Qt::Key_1: - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto & s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_index() == 1) @@ -1354,7 +1360,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) update(); break; case Qt::Key_Up: - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_vDialActive()) { @@ -1366,7 +1372,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) } break; case Qt::Key_Down: - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_vDialActive()) { diff --git a/DSView/pv/prop/binding/binding.cpp b/DSView/pv/prop/binding/binding.cpp index db9a0453..78e231ba 100755 --- a/DSView/pv/prop/binding/binding.cpp +++ b/DSView/pv/prop/binding/binding.cpp @@ -19,8 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include + #include @@ -41,7 +40,7 @@ const std::vector< boost::shared_ptr >& Binding::properties() void Binding::commit() { - BOOST_FOREACH(shared_ptr p, _properties) { + for(auto &p : _properties) { assert(p); p->commit(); } @@ -52,7 +51,7 @@ void Binding::add_properties_to_form(QFormLayout *layout, { assert(layout); - BOOST_FOREACH(shared_ptr p, _properties) + for(auto &p : _properties) { assert(p); @@ -90,7 +89,8 @@ std::map< boost::shared_ptr, { std::map < boost::shared_ptr, GVariant* > pvalue; - BOOST_FOREACH(shared_ptr p, _properties) + + for(auto &p : _properties) { assert(p); pvalue[p] = p->get_value(); diff --git a/DSView/pv/prop/binding/decoderoptions.cpp b/DSView/pv/prop/binding/decoderoptions.cpp index 644db938..df017534 100755 --- a/DSView/pv/prop/binding/decoderoptions.cpp +++ b/DSView/pv/prop/binding/decoderoptions.cpp @@ -23,7 +23,7 @@ #include "decoderoptions.h" #include -#include + #include #include diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 0774aca0..c5552d6f 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -65,21 +65,10 @@ #include #include -#include + #include "data/decode/decoderstatus.h" +#include "dsvdef.h" -//using boost::dynamic_pointer_cast; -//using boost::function; -//using boost::lock_guard; -//using boost::mutex; -//using boost::shared_ptr; -//using std::list; -//using std::map; -//using std::set; -//using std::string; -//using std::vector; -//using std::deque; -//using std::min; using namespace boost; using namespace std; @@ -99,9 +88,6 @@ SigSession::SigSession(DeviceManager *device_manager) : _repeat_hold_prg(0), _map_zoom(0) { - void *p = this; - _appCntrol = NULL; - _hotplug_handle = 0; _dev_inst = NULL; _device_manager = device_manager; @@ -110,6 +96,9 @@ SigSession::SigSession(DeviceManager *device_manager) : _hot_attach = false; _hot_detach = false; _group_cnt = 0; + _bHotplugStop = false; + _hotplug = NULL; + _sampling_thread = NULL; _feed_timer.stop(); @@ -145,7 +134,6 @@ SigSession::SigSession(DeviceManager *device_manager) : SigSession::~SigSession() { - Close(); } DevInst* SigSession::get_device() const @@ -279,7 +267,7 @@ void SigSession::release_device(DevInst *dev_inst) SigSession::capture_state SigSession::get_capture_state() const { - boost::lock_guard lock(_sampling_mutex); + std::lock_guard lock(_sampling_mutex); return _capture_state; } @@ -336,14 +324,14 @@ void SigSession::set_cur_snap_samplerate(uint64_t samplerate) // DecoderStack - BOOST_FOREACH(const boost::shared_ptr d, _decode_traces) + for(auto &d : _decode_traces) d->decoder()->set_samplerate(_cur_snap_samplerate); // Math if (_math_trace && _math_trace->enabled()) _math_trace->get_math_stack()->set_samplerate(_dev_inst->get_sample_rate()); // SpectrumStack - BOOST_FOREACH(const boost::shared_ptr m, _spectrum_traces) + for(auto & m : _spectrum_traces) m->get_spectrum_stack()->set_samplerate(_cur_snap_samplerate); cur_snap_samplerate_changed(); @@ -383,7 +371,7 @@ void SigSession::capture_init() container_init(); // update current hw offset - BOOST_FOREACH(const boost::shared_ptr s, _signals) + for(auto &s : _signals) { assert(s); boost::shared_ptr dsoSig; @@ -416,7 +404,7 @@ void SigSession::container_init() _dso_data->init(); // SpectrumStack - BOOST_FOREACH(const boost::shared_ptr m, _spectrum_traces) + for(auto &m : _spectrum_traces) { assert(m); m->get_spectrum_stack()->init(); @@ -430,7 +418,7 @@ void SigSession::container_init() //pv::data::DecoderModel *decoder_model = get_decoder_model(); //decoder_model->setDecoderStack(NULL); // DecoderStack - BOOST_FOREACH(const boost::shared_ptr d, _decode_traces) + for(auto &d : _decode_traces) { assert(d); d->decoder()->init(); @@ -459,7 +447,7 @@ void SigSession::start_capture(bool instant, // stop previous capture stop_capture(); // reset measure of dso signal - BOOST_FOREACH(const boost::shared_ptr s, _signals) + for(auto &s : _signals) { assert(s); boost::shared_ptr dsoSig; @@ -490,10 +478,11 @@ void SigSession::start_capture(bool instant, return; } - // Begin the session - _sampling_thread.reset(new boost::thread( - &SigSession::sample_thread_proc, this, _dev_inst, - error_handler)); + if (_sampling_thread && _sampling_thread->joinable()){ + _sampling_thread->join(); + } + DESTROY_OBJECT(_sampling_thread); + _sampling_thread = new std::thread(&SigSession::sample_thread_proc, this, _dev_inst, error_handler); } void SigSession::stop_capture() @@ -512,9 +501,10 @@ void SigSession::stop_capture() sr_session_stop(); // Check that sampling stopped - if (_sampling_thread.get()) + if (_sampling_thread && _sampling_thread->joinable()){ _sampling_thread->join(); - _sampling_thread.reset(); + } + DESTROY_OBJECT(_sampling_thread); } bool SigSession::get_capture_status(bool &triggered, int &progress) @@ -542,13 +532,13 @@ bool SigSession::get_capture_status(bool &triggered, int &progress) vector< boost::shared_ptr >& SigSession::get_signals() { - //boost::lock_guard lock(_signals_mutex); + //boost::lock_guard lock(_signals_mutex); return _signals; } vector< boost::shared_ptr > SigSession::get_group_signals() { - //boost::lock_guard lock(_signals_mutex); + //boost::lock_guard lock(_signals_mutex); return _group_traces; } @@ -556,7 +546,8 @@ set< boost::shared_ptr > SigSession::get_data() const { //lock_guard lock(_signals_mutex); set< boost::shared_ptr > data; - BOOST_FOREACH(const boost::shared_ptr sig, _signals) { + + for(auto &sig : _signals) { assert(sig); data.insert(sig->data()); } @@ -571,7 +562,7 @@ bool SigSession::get_instant() void SigSession::set_capture_state(capture_state state) { - boost::lock_guard lock(_sampling_mutex); + std::lock_guard lock(_sampling_mutex); _capture_state = state; data_updated(); capture_state_changed(state); @@ -606,7 +597,7 @@ void SigSession::sample_thread_proc(DevInst *dev_inst, void SigSession::check_update() { - boost::lock_guard lock(_data_mutex); + std::lock_guard lock(_data_mutex); if (_capture_state != Running) return; @@ -868,7 +859,7 @@ void SigSession::reload() void SigSession::refresh(int holdtime) { - boost::lock_guard lock(_data_mutex); + std::lock_guard lock(_data_mutex); data_lock(); @@ -876,7 +867,7 @@ void SigSession::refresh(int holdtime) _logic_data->init(); //_cur_logic_snapshot.reset(); - BOOST_FOREACH(const boost::shared_ptr d, _decode_traces) + for(auto &d : _decode_traces) { assert(d); d->decoder()->init(); @@ -886,7 +877,7 @@ void SigSession::refresh(int holdtime) if (_dso_data) { _dso_data->init(); // SpectrumStack - BOOST_FOREACH(const boost::shared_ptr m, _spectrum_traces) + for(auto &m : _spectrum_traces) { assert(m); m->get_spectrum_stack()->init(); @@ -988,7 +979,7 @@ void SigSession::feed_in_trigger(const ds_trigger_pos &trigger_pos) void SigSession::feed_in_logic(const sr_datafeed_logic &logic) { - //boost::lock_guard lock(_data_mutex); + //boost::lock_guard lock(_data_mutex); if (!_logic_data || _cur_logic_snapshot->memory_failed()) { qDebug() << "Unexpected logic packet"; return; @@ -1026,7 +1017,7 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) void SigSession::feed_in_dso(const sr_datafeed_dso &dso) { - //boost::lock_guard lock(_data_mutex); + //boost::lock_guard lock(_data_mutex); if(!_dso_data || _cur_dso_snapshot->memory_failed()) { @@ -1038,7 +1029,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) { std::map sig_enable; // reset scale of dso signal - BOOST_FOREACH(const boost::shared_ptr s, _signals) + for(auto &s : _signals) { assert(s); boost::shared_ptr dsoSig; @@ -1055,7 +1046,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) _cur_dso_snapshot->append_payload(dso); } - BOOST_FOREACH(const boost::shared_ptr s, _signals) { + for(auto &s : _signals) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s)) && (dsoSig->enabled())) dsoSig->paint_prepare(); @@ -1064,14 +1055,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) if (dso.num_samples != 0) { // update current sample rate set_cur_snap_samplerate(_dev_inst->get_sample_rate()); -// // reset measure of dso signal -// BOOST_FOREACH(const boost::shared_ptr s, _signals) -// { -// assert(s); -// boost::shared_ptr dsoSig; -// if ((dsoSig = dynamic_pointer_cast(s))) -// dsoSig->set_mValid(false); -// } + } if (_cur_dso_snapshot->memory_failed()) { @@ -1081,7 +1065,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) } // calculate related spectrum results - BOOST_FOREACH(const boost::shared_ptr m, _spectrum_traces) + for(auto &m : _spectrum_traces) { assert(m); if (m->enabled()) @@ -1105,7 +1089,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) void SigSession::feed_in_analog(const sr_datafeed_analog &analog) { - //boost::lock_guard lock(_data_mutex); + //boost::lock_guard lock(_data_mutex); if(!_analog_data || _cur_analog_snapshot->memory_failed()) { @@ -1116,7 +1100,7 @@ void SigSession::feed_in_analog(const sr_datafeed_analog &analog) if (_cur_analog_snapshot->last_ended()) { // reset scale of analog signal - BOOST_FOREACH(const boost::shared_ptr s, _signals) + for(auto &s : _signals) { assert(s); boost::shared_ptr analogSig; @@ -1149,7 +1133,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, assert(sdi); assert(packet); - boost::lock_guard lock(_data_mutex); + std::lock_guard lock(_data_mutex); if (_data_lock && packet->type != SR_DF_END) return; @@ -1203,9 +1187,9 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, case SR_DF_END: { { - //boost::lock_guard lock(_data_mutex); + //boost::lock_guard lock(_data_mutex); if (!_cur_logic_snapshot->empty()) { - BOOST_FOREACH(const boost::shared_ptr g, _group_traces) + for(auto &g : _group_traces) { assert(g); @@ -1219,7 +1203,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, _cur_dso_snapshot->capture_ended(); _cur_analog_snapshot->capture_ended(); - BOOST_FOREACH(const boost::shared_ptr d, _decode_traces) + for(auto &d : _decode_traces) d->frame_ended(); } @@ -1278,7 +1262,7 @@ void SigSession::hotplug_proc(boost::function error_handle tv.tv_sec = tv.tv_usec = 0; try { - while(_session) { + while(_session && !_bHotplugStop) { libusb_handle_events_timeout(NULL, &tv); if (_hot_attach) { qDebug("DreamSourceLab hardware attached!"); @@ -1290,7 +1274,7 @@ void SigSession::hotplug_proc(boost::function error_handle device_detach(); _hot_detach = false; } - boost::this_thread::sleep(boost::posix_time::millisec(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } catch(...) { qDebug("Interrupt exception for hotplug thread was thrown."); @@ -1324,18 +1308,21 @@ void SigSession::start_hotplug_proc(boost::function error_ qDebug() << "Starting a hotplug thread...\n"; _hot_attach = false; _hot_detach = false; - _hotplug.reset(new boost::thread( - &SigSession::hotplug_proc, this, error_handler)); + if (_hotplug && _hotplug->joinable()){ + _hotplug->join(); + } + DESTROY_OBJECT(_hotplug); + _hotplug = new std::thread(&SigSession::hotplug_proc, this, error_handler); } void SigSession::stop_hotplug_proc() -{ - if (_hotplug.get()) { - _hotplug->interrupt(); +{ + _bHotplugStop = true; + if (_hotplug && _hotplug->joinable()){ _hotplug->join(); } - _hotplug.reset(); + DESTROY_OBJECT(_hotplug); } uint16_t SigSession::get_ch_num(int type) @@ -1345,7 +1332,7 @@ uint16_t SigSession::get_ch_num(int type) uint16_t dso_ch_num = 0; uint16_t analog_ch_num = 0; if (_dev_inst->dev_inst()) { - BOOST_FOREACH(const boost::shared_ptr s, _signals) + for(auto &s : _signals) { assert(s); if (dynamic_pointer_cast(s) && s->enabled()) { @@ -1408,7 +1395,7 @@ bool SigSession::add_decoder(srd_decoder *const dec, bool silent, DecoderStatus new view::DecodeTrace(this, decoder_stack, _decode_traces.size())); // set view early for decode start/end region setting - BOOST_FOREACH(const boost::shared_ptr s, _signals) { + for(auto &s : _signals) { if (s->get_view()) { d->set_view(s->get_view()); break; @@ -1465,6 +1452,8 @@ void SigSession::remove_decode_signal(int index) { if (cur_index == index) { + auto d = (*i)->decoder().get(); + d->stop_decode(); //stop decoder thread _decode_traces.erase(i); signals_changed(); return; @@ -1522,7 +1511,7 @@ pv::data::DecoderModel* SigSession::get_decoder_model() const void SigSession::spectrum_rebuild() { bool has_dso_signal = false; - BOOST_FOREACH(const boost::shared_ptr s, _signals) { + for(auto &s : _signals) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { has_dso_signal = true; @@ -1577,7 +1566,7 @@ void SigSession::math_rebuild(bool enable, boost::shared_ptr dsoSig2, data::MathStack::MathType type) { - boost::lock_guard lock(_data_mutex); + std::lock_guard lock(_data_mutex); boost::shared_ptr math_stack( new data::MathStack(this, dsoSig1, dsoSig2, type)); _math_trace.reset(new view::MathTrace(enable, math_stack, dsoSig1, dsoSig2)); @@ -1760,7 +1749,7 @@ int SigSession::get_map_zoom() const void SigSession::auto_end() { - BOOST_FOREACH(const boost::shared_ptr s, _signals) { + for(auto &s : _signals) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { dsoSig->auto_end(); @@ -1827,8 +1816,6 @@ void SigSession::set_stop_scale(float scale) sr_dev_inst* SigSession::get_dev_inst_c() { - void *p = this; - void *p2 = this->_appCntrol; if (_dev_inst != NULL){ return _dev_inst->dev_inst(); } @@ -1844,7 +1831,7 @@ void SigSession::set_stop_scale(float scale) { if (_session == NULL) return; - + stop_capture(); ds_trigger_destroy(); @@ -1861,7 +1848,7 @@ void SigSession::set_stop_scale(float scale) { stop_hotplug_proc(); deregister_hotplug_callback(); - _hotplug_handle = NULL; + _hotplug_handle = 0; } } diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 3e2b8fb3..9cd6324e 100755 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -26,8 +26,7 @@ #include #include #include -#include -#include +#include #include #include @@ -386,10 +385,8 @@ private slots: void nodata_timeout(); void feed_timeout(); void repeat_update(); - -public: - void *_appCntrol; - + + private: DeviceManager *_device_manager; @@ -398,13 +395,13 @@ private: */ DevInst *_dev_inst; - mutable boost::mutex _sampling_mutex; + mutable std::mutex _sampling_mutex; capture_state _capture_state; bool _instant; uint64_t _cur_snap_samplerate; uint64_t _cur_samplelimits; - //mutable boost::mutex _signals_mutex; + //mutable std::mutex _signals_mutex; std::vector< boost::shared_ptr > _signals; std::vector< boost::shared_ptr > _group_traces; @@ -415,7 +412,7 @@ private: boost::shared_ptr _lissajous_trace; boost::shared_ptr _math_trace; - mutable boost::mutex _data_mutex; + mutable std::mutex _data_mutex; boost::shared_ptr _logic_data; boost::shared_ptr _cur_logic_snapshot; boost::shared_ptr _dso_data; @@ -426,10 +423,12 @@ private: boost::shared_ptr _cur_group_snapshot; int _group_cnt; - std::unique_ptr _sampling_thread; + std::thread *_sampling_thread; + std::thread *_hotplug; + volatile bool _bHotplugStop; libusb_hotplug_callback_handle _hotplug_handle; - std::unique_ptr _hotplug; + bool _hot_attach; bool _hot_detach; @@ -461,6 +460,7 @@ private: bool _dso_feed; float _stop_scale; + private: // TODO: This should not be necessary. Multiple concurrent diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index aed18575..230fd51a 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -39,26 +39,13 @@ #include #include #include - -#include + #include #include #include "config/appconfig.h" - -using boost::dynamic_pointer_cast; -using boost::mutex; -using boost::thread; -using boost::lock_guard; -using std::deque; -using std::make_pair; -using std::min; -using std::pair; -using std::set; -using std::string; -using std::vector; - + namespace pv { char chunk_name[30] = {0}; @@ -82,7 +69,7 @@ StoreSession::StoreSession(SigSession *session) : _unit_count(0), _has_error(false), _canceled(false) -{ +{ } StoreSession::~StoreSession() @@ -114,9 +101,8 @@ void StoreSession::wait() } void StoreSession::cancel() -{ - _canceled = true; - _thread.interrupt(); +{ + _canceled = true; } QList StoreSession::getSuportedExportFormats(){ @@ -147,7 +133,7 @@ bool StoreSession::save_start() } std::set type_set; - BOOST_FOREACH(const boost::shared_ptr sig, _session->get_signals()) { + for(auto &sig : _session->get_signals()) { assert(sig); type_set.insert(sig->get_type()); } @@ -190,7 +176,7 @@ bool StoreSession::save_start() if (ret != SR_OK) { _error = tr("Failed to create zip file. Initialization error."); } else { - _thread = boost::thread(&StoreSession::save_proc, this, snapshot); + _thread = std::thread(&StoreSession::save_proc, this, snapshot); return !_has_error; } } @@ -208,7 +194,8 @@ bool StoreSession::save_start() } else { - _thread = boost::thread(&StoreSession::save_proc, this, snapshot); + if (_thread.joinable()) _thread.join(); + _thread = std::thread(&StoreSession::save_proc, this, snapshot); return !_has_error; } } @@ -230,7 +217,7 @@ void StoreSession::save_proc(boost::shared_ptr snapshot) if ((logic_snapshot = boost::dynamic_pointer_cast(snapshot))) { uint16_t to_save_probes = 0; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { if (s->enabled() && logic_snapshot->has_data(s->get_index())) to_save_probes++; } @@ -238,13 +225,13 @@ void StoreSession::save_proc(boost::shared_ptr snapshot) num = logic_snapshot->get_block_num(); bool sample; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { int ch_type = s->get_type(); if (ch_type == SR_CHANNEL_LOGIC) { int ch_index = s->get_index(); if (!s->enabled() || !logic_snapshot->has_data(ch_index)) continue; - for (int i = 0; !boost::this_thread::interruption_requested() && i < num; i++) { + for (int i = 0; !_canceled && i < num; i++) { uint8_t *buf = logic_snapshot->get_block_buf(i, ch_index, sample); uint64_t size = logic_snapshot->get_block_size(i); bool need_malloc = (buf == NULL); @@ -283,7 +270,7 @@ void StoreSession::save_proc(boost::shared_ptr snapshot) } } else { int ch_type = -1; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + for(auto &s : _session->get_signals()) { ch_type = s->get_type(); break; } @@ -297,7 +284,7 @@ void StoreSession::save_proc(boost::shared_ptr snapshot) const uint8_t *buf_start = (uint8_t *)snapshot->get_data(); const uint8_t *buf_end = buf_start + _unit_count; - for (int i = 0; !boost::this_thread::interruption_requested() && i < num; i++) { + for (int i = 0; !_canceled && i < num; i++) { const uint64_t size = snapshot->get_block_size(i); if ((buf + size) > buf_end) { uint8_t *tmp = (uint8_t *)malloc(size); @@ -557,7 +544,7 @@ QString StoreSession::meta_gen(boost::shared_ptr snapshot) bool StoreSession::export_start() { std::set type_set; - BOOST_FOREACH(const boost::shared_ptr sig, _session->get_signals()) { + for(auto &sig : _session->get_signals()) { assert(sig); int _tp = sig->get_type(); type_set.insert(_tp); @@ -609,7 +596,8 @@ bool StoreSession::export_start() } else { - _thread = boost::thread(&StoreSession::export_proc, this, snapshot); + if (_thread.joinable()) _thread.join(); + _thread = std::thread(&StoreSession::export_proc, this, snapshot); return !_has_error; } @@ -716,12 +704,12 @@ void StoreSession::export_proc(boost::shared_ptr snapshot) std::vector buf_vec; std::vector buf_sample; - for (int blk = 0; !boost::this_thread::interruption_requested() && - blk < blk_num; blk++) { + for (int blk = 0; !_canceled && blk < blk_num; blk++) { uint64_t buf_sample_num = logic_snapshot->get_block_size(blk) * 8; buf_vec.clear(); buf_sample.clear(); - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { int ch_type = s->get_type(); if (ch_type == SR_CHANNEL_LOGIC) { int ch_index = s->get_index(); @@ -738,8 +726,7 @@ void StoreSession::export_proc(boost::shared_ptr snapshot) unsigned int size = usize; struct sr_datafeed_logic lp; - for(uint64_t i = 0; !boost::this_thread::interruption_requested() && - i < buf_sample_num; i+=usize){ + for(uint64_t i = 0; !_canceled && i < buf_sample_num; i+=usize){ if(buf_sample_num - i < usize) size = buf_sample_num - i; uint8_t *xbuf = (uint8_t *)malloc(size * unitsize); @@ -786,7 +773,7 @@ void StoreSession::export_proc(boost::shared_ptr snapshot) unsigned int size = usize; struct sr_datafeed_dso dp; - for(uint64_t i = 0; !boost::this_thread::interruption_requested() && i < _unit_count; i+=usize){ + for(uint64_t i = 0; !_canceled && i < _unit_count; i+=usize){ if(_unit_count - i < usize) size = _unit_count - i; @@ -813,7 +800,7 @@ void StoreSession::export_proc(boost::shared_ptr snapshot) unsigned int size = usize; struct sr_datafeed_analog ap; - for(uint64_t i = 0; !boost::this_thread::interruption_requested() && i < _unit_count; i+=usize){ + for(uint64_t i = 0; !_canceled && i < _unit_count; i+=usize){ if(_unit_count - i < usize) size = _unit_count - i; ap.data = &datat[i*snapshot->get_channel_num()]; @@ -879,13 +866,15 @@ QString StoreSession::decoders_gen() QJsonArray StoreSession::json_decoders() { QJsonArray dec_array; - BOOST_FOREACH(boost::shared_ptr t, _session->get_decode_signals()) { + + for(auto &t : _session->get_decode_signals()) { QJsonObject dec_obj; QJsonArray stack_array; QJsonObject show_obj; const boost::shared_ptr& stack = t->decoder(); const std::list< boost::shared_ptr >& decoder = stack->stack(); - BOOST_FOREACH(boost::shared_ptr dec, decoder) { + + for(auto &dec : decoder) { QJsonArray ch_array; const srd_decoder *const d = dec->decoder();; const bool have_probes = (d->channels || d->opt_channels) != 0; @@ -997,7 +986,8 @@ void StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray dec_arra } const std::list< boost::shared_ptr >& decoder = stack->stack(); - BOOST_FOREACH(boost::shared_ptr dec, decoder) { + + for(auto &dec : decoder) { const srd_decoder *const d = dec->decoder(); QJsonObject options_obj; @@ -1271,7 +1261,7 @@ QString StoreSession::MakeExportFile(bool bDlg) bool StoreSession::IsLogicDataType() { std::set type_set; - BOOST_FOREACH(const boost::shared_ptr sig, _session->get_signals()) { + for(auto &sig : _session->get_signals()) { assert(sig); type_set.insert(sig->get_type()); } diff --git a/DSView/pv/storesession.h b/DSView/pv/storesession.h index 45bd1e9a..2a671365 100755 --- a/DSView/pv/storesession.h +++ b/DSView/pv/storesession.h @@ -24,8 +24,8 @@ #include #include - -#include +#include + #include #include @@ -106,7 +106,7 @@ private: QString _suffix; SigSession *_session; - boost::thread _thread; + std::thread _thread; const struct sr_output_module* _outModule; @@ -114,8 +114,8 @@ private: uint64_t _unit_count; bool _has_error; QString _error; - bool _canceled; - ZipMaker m_zipDoc; + volatile bool _canceled; + ZipMaker m_zipDoc; }; } // pv diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/pv/toolbars/filebar.cpp index 8db6d486..7c6e7880 100755 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/pv/toolbars/filebar.cpp @@ -20,7 +20,7 @@ */ #include -#include + #include #include @@ -167,6 +167,7 @@ void FileBar::session_error( void FileBar::show_session_error( const QString text, const QString info_text) { + (void)text; MsgBox::Show(NULL, info_text.toStdString().c_str(), this); } diff --git a/DSView/pv/toolbars/logobar.cpp b/DSView/pv/toolbars/logobar.cpp index 6791226a..4c65cf41 100755 --- a/DSView/pv/toolbars/logobar.cpp +++ b/DSView/pv/toolbars/logobar.cpp @@ -20,7 +20,7 @@ */ #include -#include + #include #include diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 2ecd10b0..5efe3265 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -23,7 +23,7 @@ #include #include -#include + #include #include @@ -332,7 +332,8 @@ void SamplingBar::on_configure() void SamplingBar::zero_adj() { boost::shared_ptr dsoSig; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) + + for(auto &s : _session->get_signals()) { if ((dsoSig = dynamic_pointer_cast(s))) dsoSig->set_enable(true); @@ -349,7 +350,7 @@ void SamplingBar::zero_adj() pv::dialogs::WaitingDialog wait(this, _session, SR_CONF_ZERO); if (wait.start() == QDialog::Rejected) { - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) + for(auto &s : _session->get_signals()) { if ((dsoSig = dynamic_pointer_cast(s))) dsoSig->commit_settings(); @@ -375,7 +376,7 @@ bool SamplingBar::get_instant() const void SamplingBar::set_sampling(bool sampling) { - lock_guard lock(_sampling_mutex); + lock_guard lock(_sampling_mutex); _sampling = sampling; if (!sampling) { diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index f4addaef..833795d0 100755 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -136,7 +136,7 @@ namespace pv private: SigSession *_session; - mutable boost::recursive_mutex _sampling_mutex; + mutable std::mutex _sampling_mutex; bool _enable; bool _sampling; diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index b81be63e..07816c28 100755 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -23,7 +23,7 @@ #include -#include + #include #include @@ -127,9 +127,8 @@ DecodeTrace::DecodeTrace(pv::SigSession *session, _end_index(0), _start_count(0), _end_count(0), - _progress(0), - _popup_form(NULL), - _popup() + _progress(0), + _popup(NULL) { assert(_decoder_stack); @@ -150,6 +149,11 @@ DecodeTrace::~DecodeTrace() _decoder_forms.clear(); _probe_selectors.clear(); _bindings.clear(); + + if (_popup){ + delete _popup; + _popup = NULL; + } } bool DecodeTrace::enabled() const @@ -268,11 +272,13 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo samples_per_pixel, 0.0); uint64_t end_sample = (uint64_t)max((right + pixels_offset) * samples_per_pixel, 0.0); - BOOST_FOREACH(const boost::shared_ptr &dec, _decoder_stack->stack()) { + + for(auto &dec : _decoder_stack->stack()) { start_sample = max(dec->decode_start(), start_sample); end_sample = min(dec->decode_end(), end_sample); break; } + if (end_sample < start_sample) return; @@ -284,8 +290,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo assert(_decoder_stack); - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec :_decoder_stack->stack()) { if (dec->shown()) { const std::map rows = _decoder_stack->get_rows_gshow(); for (std::map::const_iterator i = rows.begin(); @@ -302,14 +307,16 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo const uint64_t max_annotation = _decoder_stack->get_max_annotation(row); const double max_annWidth = max_annotation / samples_per_pixel; + if ((max_annWidth > 100) || (max_annWidth > 10 && min_annWidth > 1) || (max_annWidth == 0 && samples_per_pixel < 10)) { vector annotations; _decoder_stack->get_annotation_subset(annotations, row, start_sample, end_sample); + if (!annotations.empty()) { - BOOST_FOREACH(const Annotation &a, annotations) + for(Annotation &a : annotations) draw_annotation(a, p, get_text_colour(), annotation_height, left, right, samples_per_pixel, pixels_offset, y, @@ -345,6 +352,11 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right, QColor fore, QCol //to show decoder's property setting dialog bool DecodeTrace::create_popup() { + if (_popup != NULL){ + _popup->reload(); + return true; + } + int ret = false; _popup = new dialogs::DSDialog(); @@ -352,8 +364,7 @@ bool DecodeTrace::create_popup() if (QDialog::Accepted == _popup->exec()) { - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) + for(auto &dec : _decoder_stack->stack()) { if (dec->commit() || _decoder_stack->options_changed()) { _decoder_stack->set_options_changed(true); @@ -374,11 +385,8 @@ void DecodeTrace::create_popup_form() // Transfer the layout and the child widgets to a temporary widget // which then goes out of scope destroying the layout and all the child - // widgets. - if (_popup_form) - _popup->reload(); - - _popup_form = new QFormLayout(); + // widgets. + QFormLayout *_popup_form = new QFormLayout(); _popup_form->setVerticalSpacing(5); _popup_form->setFormAlignment(Qt::AlignLeft); _popup_form->setLabelAlignment(Qt::AlignLeft); @@ -402,7 +410,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) _probe_selectors.clear(); _decoder_forms.clear(); - const list< boost::shared_ptr >& stack = _decoder_stack->stack(); + list< boost::shared_ptr >& stack = _decoder_stack->stack(); if (stack.empty()) { QLabel *const l = new QLabel( @@ -410,8 +418,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) l->setAlignment(Qt::AlignCenter); form->addRow(l); } else { - BOOST_FOREACH(boost::shared_ptr dec,stack) { - //boost::shared_ptr dec(*iter); + for(auto &dec : stack) { create_decoder_form(_decoder_stack, dec, parent, form); } @@ -419,9 +426,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) tr("* Required channels"), parent)); } - //public input layer - // QFormLayout *publay = new QFormLayout(); - // form->addRow(publay); + //Add region combobox _start_comboBox = new QComboBox(parent); @@ -526,15 +531,15 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, draw_range(a, p, fill, outline, text_color, h, start, end, y, fore, back); if ((a.type()/100 == 2) && (end - start > 20)) { - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { for (auto& iter: dec->channels()) { int type = dec->get_channel_type(iter.first); if ((type == SRD_CHANNEL_COMMON) || ((type%100 != a.type()%100) && (type%100 != 0))) continue; boost::shared_ptr logic_sig; - BOOST_FOREACH(boost::shared_ptr sig, _session->get_signals()) { + + for(auto &sig : _session->get_signals()) { if((sig->get_index() == iter.second) && (logic_sig = dynamic_pointer_cast(sig))) { logic_sig->paint_mark(p, start, end, type/100); @@ -644,7 +649,7 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, QString best_annotation; int best_width = 0; - BOOST_FOREACH(const QString &a, annotations) { + for(auto &&a : annotations) { const int w = p.boundingRect(QRectF(), 0, a).width(); if (w <= rect.width() && w > best_width) best_annotation = a, best_width = w; @@ -812,7 +817,7 @@ void DecodeTrace::commit_decoder_probes(boost::shared_ptr const vector< boost::shared_ptr > sigs(_session->get_signals()); _index_list.clear(); - BOOST_FOREACH(const ProbeSelector &s, _probe_selectors) + for(auto &s : _probe_selectors) { if(s._decoder != dec) break; @@ -820,7 +825,7 @@ void DecodeTrace::commit_decoder_probes(boost::shared_ptr const int selection = s._combo->itemData( s._combo->currentIndex()).value(); - BOOST_FOREACH(boost::shared_ptr sig, sigs) + for(auto &sig : sigs) if(sig->get_index() == selection) { probe_map[s._pdch] = selection; _index_list.push_back(selection); @@ -834,11 +839,8 @@ void DecodeTrace::commit_decoder_probes(boost::shared_ptr void DecodeTrace::commit_probes() { assert(_decoder_stack); - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) - commit_decoder_probes(dec); - - //_decoder_stack->begin_decode(); + for(auto &dec : _decoder_stack->stack()) + commit_decoder_probes(dec); } void DecodeTrace::on_new_decode_data() @@ -911,8 +913,7 @@ int DecodeTrace::rows_size() using pv::data::decode::Decoder; int size = 0; - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { if (dec->shown()) { const std::map rows = _decoder_stack->get_rows_gshow(); for (std::map::const_iterator i = rows.begin(); @@ -1000,8 +1001,7 @@ void DecodeTrace::on_region_set(int index) _start_index = index1; _end_index = index2; - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { dec->set_decode_region(decode_start, decode_end); } } @@ -1018,8 +1018,7 @@ void DecodeTrace::frame_ended() _decode_end = last_samples; _end_index = 0; } - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { dec->set_decode_region(_decode_start, _decode_end); dec->commit(); } diff --git a/DSView/pv/view/decodetrace.h b/DSView/pv/view/decodetrace.h index ee2ae804..19e8015f 100755 --- a/DSView/pv/view/decodetrace.h +++ b/DSView/pv/view/decodetrace.h @@ -223,8 +223,7 @@ private: std::vector _decoder_forms; std::vector _cur_row_headings; - - QFormLayout *_popup_form; + dialogs::DSDialog *_popup; }; diff --git a/DSView/pv/view/devmode.cpp b/DSView/pv/view/devmode.cpp index 05659b20..e34408b6 100755 --- a/DSView/pv/view/devmode.cpp +++ b/DSView/pv/view/devmode.cpp @@ -27,8 +27,7 @@ #include "../device/file.h" #include - -#include + #include #include diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index 615f2d31..7a295c5c 100755 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -30,7 +30,7 @@ #include "../sigsession.h" #include "../device/devinst.h" -#include + #include #include diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index ec5db76c..c5c44314 100755 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -35,7 +35,7 @@ #include -#include + #include #include @@ -107,7 +107,7 @@ boost::shared_ptr Header::get_mTrace( const vector< boost::shared_ptr > traces( _view.get_traces(ALL_VIEW)); - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) { assert(t); @@ -136,7 +136,8 @@ void Header::paintEvent(QPaintEvent*) const bool dragging = !_drag_traces.empty(); QColor fore(QWidget::palette().color(QWidget::foregroundRole())); fore.setAlpha(View::ForeAlpha); - BOOST_FOREACH(const boost::shared_ptr t, traces) + + for(auto &t : traces) { assert(t); // auto ptr = t.get(); @@ -157,13 +158,13 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event) _mouse_down_point = event->pos(); // Save the offsets of any Traces which will be dragged - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t->selected()) _drag_traces.push_back( make_pair(t, t->get_v_offset())); // Select the Trace if it has been clicked - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t->mouse_double_click(width(), event->pos())) break; } @@ -186,7 +187,7 @@ void Header::mousePressEvent(QMouseEvent *event) _mouse_down_point = event->pos(); // Save the offsets of any Traces which will be dragged - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t->selected()) _drag_traces.push_back( make_pair(t, t->get_v_offset())); @@ -207,14 +208,14 @@ void Header::mousePressEvent(QMouseEvent *event) mTrace->set_old_v_offset(mTrace->get_v_offset()); } - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t->mouse_press(width(), event->pos())) break; if (~QApplication::keyboardModifiers() & Qt::ControlModifier) { // Unselect all other Traces because the Ctrl is not // pressed - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t != mTrace) t->select(false); } @@ -248,7 +249,7 @@ void Header::mouseReleaseEvent(QMouseEvent *event) const vector< boost::shared_ptr > traces( _view.get_traces(ALL_VIEW)); - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) t->select(false); } @@ -288,7 +289,7 @@ void Header::wheelEvent(QWheelEvent *event) #else shift = event->delta() / 80.0; #endif - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) if (t->mouse_wheel(width(), event->pos(), shift)) break; update(); diff --git a/DSView/pv/view/lissajoustrace.cpp b/DSView/pv/view/lissajoustrace.cpp index f2c5959c..f1d307cc 100755 --- a/DSView/pv/view/lissajoustrace.cpp +++ b/DSView/pv/view/lissajoustrace.cpp @@ -30,7 +30,7 @@ #include "../sigsession.h" #include "../device/devinst.h" -#include + #include #include diff --git a/DSView/pv/view/mathtrace.cpp b/DSView/pv/view/mathtrace.cpp index fe838d9b..a61db919 100755 --- a/DSView/pv/view/mathtrace.cpp +++ b/DSView/pv/view/mathtrace.cpp @@ -31,8 +31,7 @@ #include "../sigsession.h" #include "../device/devinst.h" #include "../view/dsosignal.h" - -#include + #include #include diff --git a/DSView/pv/view/spectrumtrace.cpp b/DSView/pv/view/spectrumtrace.cpp index 64500c52..bb0ffcb9 100755 --- a/DSView/pv/view/spectrumtrace.cpp +++ b/DSView/pv/view/spectrumtrace.cpp @@ -22,7 +22,7 @@ #include #include -#include + #include #include "spectrumtrace.h" @@ -294,7 +294,8 @@ void SpectrumTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QCo double vdiv = 0; double vfactor = 0; - BOOST_FOREACH(const boost::shared_ptr s, _session->get_signals()) { + + for(auto &s : _session->get_signals()) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if(dsoSig->get_index() == _spectrum_stack->get_index()) { diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index d9bb13d1..64220412 100755 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -23,8 +23,7 @@ #include #include #include - -#include + #include #include @@ -389,22 +388,22 @@ vector< boost::shared_ptr > View::get_traces(int type) const vector< boost::shared_ptr > spectrums(_session->get_spectrum_traces()); vector< boost::shared_ptr > traces; - BOOST_FOREACH(boost::shared_ptr t, sigs) { + for(auto &t : sigs) { if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) traces.push_back(t); } - BOOST_FOREACH(boost::shared_ptr t, decode_sigs) { + for(auto &t : decode_sigs) { if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) traces.push_back(t); } - BOOST_FOREACH(boost::shared_ptr t, groups) { + for(auto &t : groups) { if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) traces.push_back(t); } - BOOST_FOREACH(boost::shared_ptr t, spectrums) { + for(auto &t : spectrums) { if (type == ALL_VIEW || _trace_view_map[t->get_type()] == type) traces.push_back(t); } @@ -586,15 +585,18 @@ const QPoint& View::hover_point() const void View::normalize_layout() { - const vector< boost::shared_ptr > traces(get_traces(ALL_VIEW)); + vector< boost::shared_ptr > traces(get_traces(ALL_VIEW)); int v_min = INT_MAX; - BOOST_FOREACH(const boost::shared_ptr t, traces) - v_min = min(t->get_v_offset(), v_min); + for(auto &t : traces){ + v_min = min(t->get_v_offset(), v_min); + } const int delta = -min(v_min, 0); - BOOST_FOREACH(boost::shared_ptr t, traces) + + for(auto &t : traces){ t->set_v_offset(t->get_v_offset() + delta); + } verticalScrollBar()->setSliderPosition(delta); v_scroll_value_changed(verticalScrollBar()->sliderPosition()); @@ -696,7 +698,7 @@ void View::signals_changed() vector< boost::shared_ptr > time_traces; vector< boost::shared_ptr > fft_traces; - BOOST_FOREACH(const boost::shared_ptr t, get_traces(ALL_VIEW)) { + for(auto &t : get_traces(ALL_VIEW)) { if (_trace_view_map[t->get_type()] == TIME_VIEW) time_traces.push_back(t); else if (_trace_view_map[t->get_type()] == FFT_VIEW) @@ -711,7 +713,7 @@ void View::signals_changed() _viewport_list.push_back(_fft_viewport); _vsplitter->refresh(); } - BOOST_FOREACH(boost::shared_ptr t, fft_traces) { + for(auto &t : fft_traces) { t->set_view(this); t->set_viewport(_fft_viewport); t->set_totalHeight(_fft_viewport->height()); @@ -732,7 +734,7 @@ void View::signals_changed() } if (!time_traces.empty() && _time_viewport) { - BOOST_FOREACH(const boost::shared_ptr t, time_traces) { + for(auto &t : time_traces) { assert(t); if (dynamic_pointer_cast(t) || t->enabled()) @@ -766,7 +768,8 @@ void View::signals_changed() } _spanY = _signalHeight + 2 * actualMargin; int next_v_offset = actualMargin; - BOOST_FOREACH(boost::shared_ptr t, time_traces) { + + for(auto &t : time_traces) { t->set_view(this); t->set_viewport(_time_viewport); if (t->rows_size() == 0) @@ -847,7 +850,7 @@ int View::headerWidth() const vector< boost::shared_ptr > traces(get_traces(ALL_VIEW)); if (!traces.empty()) { - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(), headerWidth); } @@ -1090,7 +1093,7 @@ QRect View::get_view_rect() { if (_session->get_device()->dev_inst()->mode == DSO) { const vector< boost::shared_ptr > sigs(_session->get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { return s->get_view_rect(); } } @@ -1103,7 +1106,7 @@ int View::get_view_width() int view_width = 0; if (_session->get_device()->dev_inst()->mode == DSO) { const vector< boost::shared_ptr > sigs(_session->get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { view_width = max(view_width, s->get_view_rect().width()); } } else { @@ -1118,7 +1121,7 @@ int View::get_view_height() int view_height = 0; if (_session->get_device()->dev_inst()->mode == DSO) { const vector< boost::shared_ptr > sigs(_session->get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { view_height = max(view_height, s->get_view_rect().height()); } } else { @@ -1193,7 +1196,7 @@ void View::show_region(uint64_t start, uint64_t end, bool keep) void View::viewport_update() { _viewcenter->update(); - BOOST_FOREACH(QWidget *viewport, _viewport_list) + for(QWidget *viewport : _viewport_list) viewport->update(); } diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index f4c475f6..5c548e63 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -39,7 +39,7 @@ #include #include #include -#include + #include "../config/appconfig.h" @@ -112,7 +112,7 @@ int Viewport::get_total_height() const int h = 0; const vector< boost::shared_ptr > traces(_view.get_traces(_type)); - BOOST_FOREACH(const boost::shared_ptr t, traces) { + for(auto &t : traces) { assert(t); h += (int)(t->get_totalHeight()); } @@ -150,7 +150,8 @@ void Viewport::paintEvent(QPaintEvent *event) fore.setAlpha(View::ForeAlpha); _view.set_back(false); const vector< boost::shared_ptr > traces(_view.get_traces(_type)); - BOOST_FOREACH(const boost::shared_ptr t, traces) + + for(auto &t : traces) { assert(t); @@ -186,7 +187,7 @@ void Viewport::paintEvent(QPaintEvent *event) paintSignals(p, fore, back); } - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) { assert(t); if (t->enabled()) @@ -203,7 +204,8 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) { const vector< boost::shared_ptr > traces(_view.get_traces(_type)); if (_view.session().get_device()->dev_inst()->mode == LOGIC) { - BOOST_FOREACH(const boost::shared_ptr t, traces) + + for(auto &t : traces) { assert(t); // auto ptr = t.get(); @@ -227,7 +229,7 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) QPainter dbp(&pixmap); //dbp.begin(this); - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) { assert(t); @@ -520,7 +522,8 @@ void Viewport::mousePressEvent(QMouseEvent *event) event->button() == Qt::LeftButton && _view.session().get_device()->dev_inst()->mode == DSO) { const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { assert(s); if (!s->enabled()) continue; @@ -637,7 +640,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) } _drag_strength = (_mouse_down_point - event->pos()).x(); } else if (_type == FFT_VIEW) { - BOOST_FOREACH(const boost::shared_ptr t, _view.session().get_spectrum_traces()) { + for(auto &t: _view.session().get_spectrum_traces()) { assert(t); if(t->enabled()) { double delta = (_mouse_point - event->pos()).x(); @@ -667,7 +670,8 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) uint64_t index0 = 0, index1 = 0, index2 = 0; bool logic = false; const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s: sigs) { assert(s); boost::shared_ptr logicSig; boost::shared_ptr dsoSig; @@ -730,7 +734,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) } if (!(event->buttons() | Qt::NoButton)) { if (_action_type == DSO_XM_STEP1 || _action_type == DSO_XM_STEP2) { - BOOST_FOREACH(const boost::shared_ptr s, _view.session().get_signals()) { + for(auto &s : _view.session().get_signals()) { assert(s); if (!s->get_view_rect().contains(event->pos())) { clear_dso_xm(); @@ -784,7 +788,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event) if (_action_type == NO_ACTION) { if (_mouse_down_point.x() == event->pos().x()) { const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { assert(s); boost::shared_ptr logicSig; if ((logicSig = dynamic_pointer_cast(s))) { @@ -807,7 +812,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event) if (_action_type == NO_ACTION) { if (_mouse_down_point.x() == event->pos().x()) { const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { assert(s); if (abs(event->pos().y() - s->get_y()) < _view.get_signalHeight()) { _action_type = LOGIC_EDGE; @@ -844,7 +850,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event) const vector< boost::shared_ptr > traces( _view.get_traces(ALL_VIEW)); - BOOST_FOREACH(const boost::shared_ptr t, traces) + for(auto &t : traces) t->select(false); } } else if (_action_type == DSO_XM_STEP0) { @@ -961,7 +967,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event) uint64_t index0 = 0, index1 = 0, index2 = 0; if (_view.session().get_device()->dev_inst()->mode == LOGIC) { const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { assert(s); boost::shared_ptr logicSig; if ((logicSig = dynamic_pointer_cast(s))) { @@ -994,7 +1000,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event) clear_dso_xm(); measure_updated(); } else if (_action_type == NO_ACTION) { - BOOST_FOREACH(const boost::shared_ptr s, _view.session().get_signals()) { + for(auto &s : _view.session().get_signals()) { assert(s); if (s->get_view_rect().contains(event->pos())) { _dso_xm_index[0] = _view.pixel2index(event->pos().x()); @@ -1020,7 +1026,7 @@ void Viewport::wheelEvent(QWheelEvent *event) assert(event); if (_type == FFT_VIEW) { - BOOST_FOREACH(const boost::shared_ptr t, _view.session().get_spectrum_traces()) { + for(auto &t : _view.session().get_spectrum_traces()) { assert(t); if(t->enabled()) { t->zoom(event->delta() / 80, event->x()); @@ -1061,7 +1067,7 @@ void Viewport::wheelEvent(QWheelEvent *event) } const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { assert(s); boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { @@ -1169,7 +1175,8 @@ void Viewport::measure() if (_type == TIME_VIEW) { const uint64_t sample_rate = _view.session().cur_snap_samplerate(); const vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { assert(s); boost::shared_ptr logicSig; boost::shared_ptr dsoSig; @@ -1251,7 +1258,7 @@ void Viewport::measure() } } } else if (_type == FFT_VIEW) { - BOOST_FOREACH(const boost::shared_ptr t, _view.session().get_spectrum_traces()) { + for(auto &t : _view.session().get_spectrum_traces()) { assert(t); if(t->enabled()) { t->measure(_mouse_point); @@ -1325,7 +1332,8 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back) const vector< boost::shared_ptr > sigs(_view.session().get_signals()); if (_action_type == NO_ACTION && _measure_type == DSO_VALUE) { - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { boost::shared_ptr dsoSig; boost::shared_ptr analogSig; if ((dsoSig = dynamic_pointer_cast(s))) { @@ -1353,7 +1361,7 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back) } if (_dso_ym_valid) { - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + for(auto &s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) { if (dsoSig->get_index() == _dso_ym_sig_index) { diff --git a/DSView/pv/view/viewstatus.cpp b/DSView/pv/view/viewstatus.cpp index 739df933..27345f84 100755 --- a/DSView/pv/view/viewstatus.cpp +++ b/DSView/pv/view/viewstatus.cpp @@ -76,7 +76,8 @@ void ViewStatus::paintEvent(QPaintEvent *) int sig_index = std::get<1>(_mrects[i]); boost::shared_ptr dsoSig = NULL; const vector< boost::shared_ptr > sigs(_session->get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { assert(s); if (!s->enabled()) continue; @@ -187,8 +188,7 @@ void ViewStatus::mousePressEvent(QMouseEvent *event) if (_session->get_device()->dev_inst()->mode != DSO) return; - if (event->button() == Qt::LeftButton) { - //BOOST_FOREACH(QRect rect, std::get<0>(_mrects)) { + if (event->button() == Qt::LeftButton) { for(size_t i = 0; i < _mrects.size(); i++) { const QRect rect = std::get<0>(_mrects[i]); if (rect.contains(event->pos())) { diff --git a/DSView/pv/view/viewstatus.h b/DSView/pv/view/viewstatus.h index 56cfaa43..29bd473e 100755 --- a/DSView/pv/view/viewstatus.h +++ b/DSView/pv/view/viewstatus.h @@ -28,7 +28,7 @@ #include #include -#include + #include #include diff --git a/DSView/pv/view/xcursor.cpp b/DSView/pv/view/xcursor.cpp index a96daf20..eeecf6aa 100755 --- a/DSView/pv/view/xcursor.cpp +++ b/DSView/pv/view/xcursor.cpp @@ -28,8 +28,7 @@ #include "dsosignal.h" #include - -#include + using namespace boost; using namespace std; @@ -48,7 +47,8 @@ XCursor::XCursor(View &view, QColor &colour, { _dsoSig = NULL; const std::vector< boost::shared_ptr > sigs(_view.session().get_signals()); - BOOST_FOREACH(const boost::shared_ptr s, sigs) { + + for(auto &s : sigs) { boost::shared_ptr dsoSig; if ((dsoSig = dynamic_pointer_cast(s))) if (dsoSig->enabled()) { diff --git a/DSView/pv/widgets/decodergroupbox.cpp b/DSView/pv/widgets/decodergroupbox.cpp index a529c4df..2da50f7b 100755 --- a/DSView/pv/widgets/decodergroupbox.cpp +++ b/DSView/pv/widgets/decodergroupbox.cpp @@ -33,8 +33,7 @@ #include #include #include - -#include + #include "../config/appconfig.h" #include @@ -72,8 +71,7 @@ DecoderGroupBox::DecoderGroupBox(boost::shared_ptr &decoder_ } _index = 0; - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { if (dec == _dec) break; _index++; @@ -137,8 +135,8 @@ void DecoderGroupBox::tog_icon() int index = id.toInt(); if (index == -1) { int i = _index; - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + + for(auto &dec : _decoder_stack->stack()) { if (i-- == 0) { dec->show(!dec->shown()); sc->setIcon(QIcon(dec->shown() ? iconPath+"/shown.svg" : @@ -164,8 +162,7 @@ void DecoderGroupBox::tog_icon() void DecoderGroupBox::on_del_stack() { int i = _index; - BOOST_FOREACH(boost::shared_ptr dec, - _decoder_stack->stack()) { + for(auto &dec : _decoder_stack->stack()) { if (i-- == 0) { del_stack(dec); break;