def updateSelection(self):
        """Checks if the current selection is valid, and updates the selection
        if the previously selected component is not visible and enabled. The
        first visible and enabled tab is selected if the current selection is
        empty or invalid.

        This method does not fire tab change events, but the caller should do
        so if appropriate.

        @return: true if selection was changed, false otherwise
        """
        originalSelection = self._selected

        i = self.getComponentIterator()
        while True:
            try:
                component = i.next()
                tab = self._tabs.get(component)
                # If we have no selection, if the current selection is
                # invisible or if the current selection is disabled (but
                # the whole component is not) we select this tab instead
                selectedTabInfo = None
                if self._selected is not None:
                    selectedTabInfo = self._tabs.get(self._selected)

                if (self._selected is None
                        or selectedTabInfo is None
                        or not selectedTabInfo.isVisible()
                        or not selectedTabInfo.isEnabled()):
                    # The current selection is not valid so we need to
                    # change it
                    if tab.isEnabled() and tab.isVisible():
                        self._selected = component
                        break
                    else:
                        # The current selection is not valid but this
                        # tab cannot be selected either.
                        self._selected = None
            except StopIteration:
                break

        return originalSelection != self._selected
dataset/ETHPy150Open rwl/muntjac/muntjac/ui/tab_sheet.py/TabSheet.updateSelection/original