1. biolab
  2. Untitled project
  3. orange

Commits

Aleš Erjavec  committed 73f8055

Fix for a possible segfault while filtering the items in a menu.

  • Participants
  • Parent commits 8a3d999
  • Branches default

Comments (0)

Files changed (1)

File Orange/OrangeCanvas/document/quickmenu.py

View file
  • Ignore whitespace
         return QSize(width, height)
 
     def __onEntered(self, index):
-        self.view().selectionModel().select(
-            index,
-            QItemSelectionModel.ClearAndSelect
-        )
-        self.view().setCurrentIndex(index)
+        if not index.isValid():
+            return
+
+        if self.view().state() != QTreeView.NoState:
+            # The item view can emit an 'entered' signal while the model/view
+            # is being changed (rows removed). When this happens, setting the
+            # current item can segfault (in QTreeView::scrollTo).
+            return
+
+        if index.flags() & Qt.ItemIsEnabled:
+            self.view().selectionModel().setCurrentIndex(
+                index,
+                QItemSelectionModel.ClearAndSelect
+            )
 
 
 class ItemDisableFilter(QSortFilterProxyModel):