]> sigrok.org Git - pulseview.git/blobdiff - pv/view/view.cpp
AnalogSignal: Use correct scaling factor for the grid to work
[pulseview.git] / pv / view / view.cpp
index 758e7118d8e94f2cee90f8334774056b8decc2b2..b877da1e202aaaeae210e7492ea151fdc0858155 100644 (file)
@@ -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
@@ -1090,15 +1092,19 @@ void View::signals_changed()
 
        // 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<int, int> extents = item->v_extents();
+
+               if (item->enabled())
+                       offset += -extents.first;
 
-               add_child_item(item);
                item->force_to_v_offset(offset);
 
-               const pair<int, int> extents = item->v_extents();
                if (item->enabled())
-                       offset += (extents.second - extents.first);
+                       offset += extents.second;
        }
 
        update_layout();