Tue, 26 Oct 2021 17:42:19 +0200
EricIconBar: fixed an issue removing a managed item.
eric7/EricWidgets/EricIconBar.py | file | annotate | diff | comparison | revisions |
--- a/eric7/EricWidgets/EricIconBar.py Tue Oct 26 17:06:36 2021 +0200 +++ b/eric7/EricWidgets/EricIconBar.py Tue Oct 26 17:42:19 2021 +0200 @@ -272,9 +272,13 @@ """ label = self.__layout.itemAt(index) if label: - self.__layout.removeWidget(label.widget()) +# self.__layout.removeItem(label) +# self.__layout.removeWidget(label.widget()) with contextlib.suppress(IndexError): del self.__icons[index] + itm = self.__layout.takeAt(index) + itm.widget().deleteLater() + del itm if index == self.__currentIndex: self.setCurrentIndex(index) @@ -290,10 +294,11 @@ @type EricClickableLabel """ index = self.__layout.indexOf(label) - if index == self.__currentIndex: - self.currentClicked.emit(self.__currentIndex) - else: - self.setCurrentIndex(index) + if index >= 0: + if index == self.__currentIndex: + self.currentClicked.emit(self.__currentIndex) + else: + self.setCurrentIndex(index) def setCurrentIndex(self, index): """ @@ -305,11 +310,13 @@ if index >= self.count(): index = -1 - if index != self.__currentIndex: + if index != self.__currentIndex and index >= 0: # reset style of previous current icon oldLabel = self.__layout.itemAt(self.__currentIndex) if oldLabel: - oldLabel.widget().setStyleSheet("") + widget = oldLabel.widget() + if widget is not None: + widget.setStyleSheet("") # set style of new current icon newLabel = self.__layout.itemAt(index)