X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=079d8d89b38ffaec8e42b1c6a7f173e56a46bb30;hb=c3a740dd5d095eb1cdf42e00df4d5a5c480ac5b3;hp=7a55bbb3fd2776fc7c38afae05864a5e2649b683;hpb=eae6e30af53f6b3e42dc5be212c82870078276b0;p=pulseview.git diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 7a55bbb..079d8d8 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -22,9 +22,10 @@ #include #endif -#include -#include -#include +#include +#include +#include +#include #include #include @@ -46,9 +47,11 @@ using pv::data::SignalData; using std::back_inserter; using std::deque; using std::list; +using std::lock_guard; using std::max; using std::make_pair; using std::min; +using std::mutex; using std::pair; using std::set; using std::shared_ptr; @@ -214,9 +217,6 @@ void View::zoom_one_to_one() { using pv::data::SignalData; - const vector< shared_ptr > sigs( - session().get_signals()); - // Make a set of all the visible data objects set< shared_ptr > visible_data = get_visible_data(); if (visible_data.empty()) @@ -251,27 +251,6 @@ void View::set_scale_offset(double scale, double offset) scale_offset_changed(); } -vector< shared_ptr > View::child_items() const -{ - vector< shared_ptr > row_items; - - const vector< shared_ptr > sigs( - session().get_signals()); - copy(sigs.begin(), sigs.end(), back_inserter(row_items)); - -#ifdef ENABLE_DECODE - const vector< shared_ptr > decode_sigs( - session().get_decode_signals()); - copy(decode_sigs.begin(), decode_sigs.end(), back_inserter(row_items)); -#endif - - stable_sort(row_items.begin(), row_items.end(), - [](const shared_ptr &a, const shared_ptr &b) { - return a->v_offset() < b->v_offset(); }); - - return row_items; -} - list > View::selected_items() const { list > items; @@ -279,8 +258,7 @@ list > View::selected_items() const // List the selected signals const vector< shared_ptr > row_items(child_items()); for (shared_ptr r : row_items) { - assert(r); - if (r->selected()) + if (r && r->selected()) items.push_back(r); } @@ -295,8 +273,8 @@ list > View::selected_items() const set< shared_ptr > View::get_visible_data() const { - const vector< shared_ptr > sigs( - session().get_signals()); + lock_guard lock(session().signals_mutex()); + const vector< shared_ptr > &sigs(session().signals()); // Make a set of all the visible data objects set< shared_ptr > visible_data; @@ -541,10 +519,24 @@ void View::v_scroll_value_changed(int value) void View::signals_changed() { + // Populate the traces + clear_child_items(); + + lock_guard lock(session().signals_mutex()); + const vector< shared_ptr > &sigs(session().signals()); + for (auto s : sigs) + add_child_item(s); + +#ifdef ENABLE_DECODE + const vector< shared_ptr > decode_sigs( + session().get_decode_signals()); + for (auto s : decode_sigs) + add_child_item(s); +#endif + + // Create the initial layout int offset = SignalMargin + SignalHeight; - const vector< shared_ptr > row_items(child_items()); - for (shared_ptr r : row_items) { - r->set_owner(this); + for (shared_ptr r : child_items()) { r->set_v_offset(offset); offset += SignalHeight + 2 * SignalMargin; }