eric7/EricWidgets/EricModelMenu.py

branch
eric7
changeset 8420
ff89f8bac0a5
parent 8358
144a6b854f70
child 8881
54e42bc2437a
diff -r 32506bc52886 -r ff89f8bac0a5 eric7/EricWidgets/EricModelMenu.py
--- a/eric7/EricWidgets/EricModelMenu.py	Thu Jun 10 17:08:51 2021 +0200
+++ b/eric7/EricWidgets/EricModelMenu.py	Thu Jun 10 17:10:57 2021 +0200
@@ -46,12 +46,21 @@
         self.__dropRow = -1
         self.__dropIndex = None
         
+        self.menuActions = []
+        
         # This is to ensure it will be shown on Mac OS X
         self.addAction("--not populated--")
         
         self.aboutToShow.connect(self.__aboutToShow)
         self.triggered.connect(self.__actionTriggered)
     
+    def clear(self):
+        """
+        Public method to clear the menu.
+        """
+        super().clear()
+        self.menuActions.clear()
+    
     def prePopulated(self):
         """
         Public method to add any actions before the tree.
@@ -208,7 +217,8 @@
                 icon = UI.PixmapCache.getIcon("defaultIcon")
             modelMenu.setIcon(icon)
             if parentMenu is not None:
-                parentMenu.addMenu(modelMenu).setData(v)
+                self.menuActions.append(
+                    parentMenu.addMenu(modelMenu).setData(v))
             modelMenu.setRootIndex(parent)
             modelMenu.setModel(self.__model)
             return

eric ide

mercurial