X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f780e48af479e7bf9a07eaaa1ab6b41f1ffb17b..d167fc518a2f59d76f683da70a07f55bcbb95345:/wxPython/samples/ide/activegrid/tool/OutlineService.py diff --git a/wxPython/samples/ide/activegrid/tool/OutlineService.py b/wxPython/samples/ide/activegrid/tool/OutlineService.py index 95ccd9e357..c04f1ecc1f 100644 --- a/wxPython/samples/ide/activegrid/tool/OutlineService.py +++ b/wxPython/samples/ide/activegrid/tool/OutlineService.py @@ -156,11 +156,8 @@ class OutlineView(Service.ServiceView): treeCtrl.Expand(child) (child, cookie) = treeCtrl.GetNextChild(parentItem, cookie) - # wxBug: This causes a crash, tried using ScrollTo which crashed as well. Then tried calling it with wx.CallAfter and that crashed as well, with both EnsureVisible and ScrollTo - # self.GetControl().EnsureVisible(self.GetControl().GetRootItem()) - # So doing the following massive hack which forces the treectrl to scroll up to the top item - treeCtrl.Collapse(parentItem) - treeCtrl.Expand(parentItem) + if parentItem: + treeCtrl.EnsureVisible(parentItem) class OutlineTreeCtrl(wx.TreeCtrl): @@ -442,12 +439,13 @@ class OutlineService(Service.Service): if not self.GetView(): return - self.SaveExpansionState() - if view.DoLoadOutlineCallback(force=force): - self.GetView().OnSort(wx.ConfigBase_Get().ReadInt("OutlineSort", SORT_NONE)) - self.LoadExpansionState() - if position >= 0: - self.SyncToPosition(position) + if hasattr(view, "DoLoadOutlineCallback"): + self.SaveExpansionState() + if view.DoLoadOutlineCallback(force=force): + self.GetView().OnSort(wx.ConfigBase_Get().ReadInt("OutlineSort", SORT_NONE)) + self.LoadExpansionState() + if position >= 0: + self.SyncToPosition(position) def SyncToPosition(self, position): @@ -501,8 +499,8 @@ class OutlineService(Service.Service): foundRegisteredView = True break - if not foundRegisteredView: - self.GetView().ClearTreeCtrl() + if not foundRegisteredView: + self.GetView().ClearTreeCtrl() self._timer.Start(1000) # 1 second interval