pglive icon indicating copy to clipboard operation
pglive copied to clipboard

Exception on Removing Ignored Plot

Open koniho opened this issue 1 year ago • 1 comments

Removing an ignored plot results in an IndexError. It appears that LiveAxisRange.ignored_data_connectors is a list but is treated as a dict (like LiveAxisRange.x_range and LiveAxisRange.y_range) in the LiveAxisRange.remove_data_connector() call:

Resulting exception:

self.plot_widget.removeItem(...)

...

<pglive.sources.data_connector.DataConnector object at 0x7f36eff79f30> 8742120684019
Traceback (most recent call last):                                                                        
  ...
  File "/home/akho/.local/share/virtualenvs/new_srampy-tfH74orZ/lib/python3.10/site-packages/pglive/sources/live_plot_widget.py", line 70, in removeItem                                                             
    self.x_range_controller.remove_data_connector(item.data_connector)                   
  File "/home/akho/.local/share/virtualenvs/new_srampy-tfH74orZ/lib/python3.10/site-packages/pglive/sources/live_axis_range.py", line 222, in remove_data_connector
    del self.ignored_data_connectors[data_connector.__hash__()]                                                                                                                                                      
IndexError: list assignment index out of range                                                                                                                                                                       

The plot is "ignored" through clicking on the plot name on the legend which I believe ends up calling setVisible(False) on the plotitem.

I was able to work around the issue by calling setVisible(True) on any plots where isVisible() returned False

koniho avatar Aug 09 '24 16:08 koniho

Potentially naive simple solution:

class LiveAxisRange:
    ...

    def remove_data_connector(self, data_connector):
        if data_connector.__hash__() in self.ignored_data_connectors:
            self.ignored_data_connectors.remove(data_connector.__hash__())

koniho avatar Aug 09 '24 16:08 koniho

Hey! Sorry for late reply. Thanks for pointing this bug out. I used your solution to fix this :).

domarm-comat avatar Aug 29 '24 13:08 domarm-comat