X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=b877da1e202aaaeae210e7492ea151fdc0858155;hp=b7ee331f165c175bdaaf1080561b2ae31650644e;hb=7d5565237c8dae52b5a15d39f28b2964b6f79a5f;hpb=925763b09cd26608cf4b38ce7b44800948a0e5aa diff --git a/pv/view/view.cpp b/pv/view/view.cpp index b7ee331f..b877da1e 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -1038,13 +1038,15 @@ void View::signals_changed() offset += extents.second; } - // Assign proper vertical offsets to each channel in the group - new_trace_group->restack_items(); - - // If this is a new group, enqueue it in the new top level - // items list - if (!new_traces_in_group.empty() && new_trace_group) - new_top_level_items.push_back(new_trace_group); + if (new_trace_group) { + // Assign proper vertical offsets to each channel in the group + new_trace_group->restack_items(); + + // If this is a new group, enqueue it in the new top level + // items list + if (!new_traces_in_group.empty()) + new_top_level_items.push_back(new_trace_group); + } } // Enqueue the remaining logic channels in a group @@ -1083,17 +1085,26 @@ void View::signals_changed() owner->remove_child_item(trace); } + // Remove any empty trace groups + for (shared_ptr group : list_by_type()) + if (group->child_items().size() == 0) + remove_child_item(group); + // Add and position the pending top levels items for (auto item : new_top_level_items) { + add_child_item(item); + // Position the item after the last item or at the top if there is none int offset = v_extents().second; + const pair extents = item->v_extents(); + + if (item->enabled()) + offset += -extents.first; - add_child_item(item); item->force_to_v_offset(offset); - const pair extents = item->v_extents(); if (item->enabled()) - offset += (extents.second - extents.first); + offset += extents.second; } update_layout();