Skip to content

Commit

Permalink
plots: fix reinitialising series
Browse files Browse the repository at this point in the history
clear() cannot be overridden, which resulted in persistent layout items.
Clearing before removing items in self.series fixes errors of the kind

QGraphicsScene::removeItem: item 0x17a7fb9bb40's scene (0x0) is different from this scene (0x17a7f77e340)
  • Loading branch information
pmldrmota authored and dnadlinger committed Oct 7, 2023
1 parent af465a2 commit 67ab132
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions ndscan/plots/plot_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ def link_x_axes(self) -> None:
# also part of it.
pane.getAxis("bottom").setStyle(showValues=False)

def clear(self) -> None:
def clear_panes(self):
for pane in self.panes:
pane.reset_y_axes()
self.panes.clear()
super().clear()


class ContextMenuBuilder:
Expand Down
3 changes: 2 additions & 1 deletion ndscan/plots/rolling_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ def __init__(self, model: SinglePointModel, get_alternate_plot_names):
self._history_length = 1024

def _initialise_series(self):
self.clear_panes()
self.clear()
for s in self.series:
s.remove_items()
self.series.clear()
self.clear()

channels = self.model.get_channel_schemata()
try:
Expand Down
4 changes: 3 additions & 1 deletion ndscan/plots/xy_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,16 @@ def rewritten(points):

def _initialise_series(self, channels):
# Remove all currently shown items and any extra axes added.
self.clear_panes()
self.clear()
for s in self.series:
s.remove_items()
self.series.clear()
self.crosshairs.clear()
self.unique_x_data.clear()
self.found_duplicate_x_data = False
self._clear_annotations()
self.clear()

self.subscan_roots = create_subscan_roots(self.selected_point_model)

try:
Expand Down

0 comments on commit 67ab132

Please sign in to comment.