eric6/E5Gui/E5ModelToolBar.py

changeset 7628
f904d0eef264
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
--- a/eric6/E5Gui/E5ModelToolBar.py	Wed Jun 17 17:12:21 2020 +0200
+++ b/eric6/E5Gui/E5ModelToolBar.py	Wed Jun 17 20:18:54 2020 +0200
@@ -102,7 +102,8 @@
         """
         Protected slot to build the tool bar.
         """
-        assert self.__model is not None
+        if self.__model is None:
+            return
         
         self.clear()
         
@@ -197,6 +198,7 @@
         Protected method to handle drop events.
         
         @param evt reference to the event (QDropEvent)
+        @exception RuntimeError raised to indicate an invalid model index
         """
         if self.__model is not None:
             act = self.actionAt(evt.pos())
@@ -205,7 +207,8 @@
                 row = self.__model.rowCount(self.__root)
             else:
                 idx = self.index(act)
-                assert idx.isValid()
+                if not idx.isValid():
+                    raise RuntimeError("invalid index")
                 row = idx.row()
                 if self.__model.hasChildren(idx):
                     parentIndex = idx
@@ -224,6 +227,7 @@
         Protected method to handle mouse move events.
         
         @param evt reference to the event (QMouseEvent)
+        @exception RuntimeError raised to indicate an invalid model index
         """
         if self.__model is None:
             super(E5ModelToolBar, self).mouseMoveEvent(evt)
@@ -245,7 +249,8 @@
             return
         
         idx = self.index(act)
-        assert idx.isValid()
+        if not idx.isValid():
+            raise RuntimeError("invalid index")
         
         drag = QDrag(self)
         drag.setMimeData(self.__model.mimeData([idx]))

eric ide

mercurial