EricIconBar: fixed an issue removing an icon. eric7

Sat, 11 Sep 2021 13:40:06 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 11 Sep 2021 13:40:06 +0200
branch
eric7
changeset 8591
7cf4b7bc3d5a
parent 8590
3663b9de2121
child 8592
ab8580937d4b

EricIconBar: fixed an issue removing an icon.

eric7/EricWidgets/EricIconBar.py file | annotate | diff | comparison | revisions
--- a/eric7/EricWidgets/EricIconBar.py	Sat Sep 11 12:48:59 2021 +0200
+++ b/eric7/EricWidgets/EricIconBar.py	Sat Sep 11 13:40:06 2021 +0200
@@ -166,10 +166,9 @@
             iconLabel = self.__layout.itemAt(index)
             if iconLabel:
                 widget = iconLabel.widget()
-                if widget:
-                    widget.setFixedSize(self.__barSize, self.__barSize)
-                    widget.setPixmap(
-                        icon.pixmap(self.__barSize, self.__barSize))
+                widget.setFixedSize(self.__barSize, self.__barSize)
+                widget.setPixmap(
+                    icon.pixmap(self.__barSize, self.__barSize))
     
     def barSize(self):
         """
@@ -272,14 +271,15 @@
         @type int
         """
         label = self.__layout.itemAt(index)
-        self.__layout.removeWidget(label)
-        with contextlib.suppress(IndexError):
-            del self.__icons[index]
-        
-        if index == self.__currentIndex:
-            self.setCurrentIndex(index)
-        elif index < self.__currentIndex:
-            self.setCurrentIndex(self.__currentIndex - 1)
+        if label:
+            self.__layout.removeWidget(label.widget())
+            with contextlib.suppress(IndexError):
+                del self.__icons[index]
+            
+            if index == self.__currentIndex:
+                self.setCurrentIndex(index)
+            elif index < self.__currentIndex:
+                self.setCurrentIndex(self.__currentIndex - 1)
     
     @pyqtSlot()
     def __iconClicked(self, label):

eric ide

mercurial