silx-kit / silx

silx toolkit
http://www.silx.org/doc/silx/latest/
MIT License
119 stars 70 forks source link

silx.gui.data.DataViewer.DataViewer: Fixed issue with accessing views after using the removeView method. #4131

Closed malte-storm closed 3 weeks ago

malte-storm commented 3 weeks ago

Fixed issue #4130 which occured after using the silx.gui.data.DataViewer.DataViewer.removeView method which invalidated the index dictionary for accessing widgets. Switching between views modified the referenced __stack without updating the __index.

t20100 commented 3 weeks ago

Thanks for the investigation and the fix!

Looking at it, it seems self.__index is not needed and the following would simplify the code:

    def __getStackIndex(self, view):
        widget = view.getWidget()
        index = self.__stack.indexOf(widget)
        if index != -1:
            return index
        return self.__stack.addWidget(widget)

But let's keep this for later.