Skip to content

Commit

Permalink
Elements list: catch wxPython::invalid item exception when text in th…
Browse files Browse the repository at this point in the history
…e filter field yields no elements. Re #8753. (#8754)

Regression: when a user enters text into the filter field and no elements are found, wxPython returns 'invalid item' when attempting to obtain selection from the search tree. Thus coerce this to default element (initial element).
  • Loading branch information
josephsl authored and michaelDCurran committed Sep 18, 2018
1 parent 427af6a commit 2bb49ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/browseMode.py
Expand Up @@ -887,7 +887,11 @@ def initElementType(self, elType):
def filter(self, filterText, newElementType=False):
# If this is a new element type, use the element nearest the cursor.
# Otherwise, use the currently selected element.
defaultElement = self._initialElement if newElementType else self.tree.GetItemData(self.tree.GetSelection())
# #8753: wxPython 4 returns "invalid tree item" when the tree view is empty, so use initial element if appropriate.
try:
defaultElement = self._initialElement if newElementType else self.tree.GetItemData(self.tree.GetSelection())
except:
defaultElement = self._initialElement
# Clear the tree.
self.tree.DeleteChildren(self.treeRoot)

Expand Down

0 comments on commit 2bb49ee

Please sign in to comment.