Skip to content

Commit 04a5596

Browse files
Remove _ActionHandler Inheritance of wx.window, it's not necessary at all, and this could improve the tree plugin's performance significantly. (#2237)
Co-authored-by: Hélio Guilherme <[email protected]>
1 parent 0c9d604 commit 04a5596

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/robotide/ui/treenodehandlers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def action_handler_class(controller):
5555
}[controller.__class__]
5656

5757

58-
class _ActionHandler(wx.Window):
58+
class _ActionHandler:
5959
is_user_keyword = False
6060
is_test_suite = False
6161
is_variable = False
@@ -88,13 +88,11 @@ class _ActionHandler(wx.Window):
8888
_label_open_folder = 'Open Containing Folder'
8989

9090
def __init__(self, controller, tree, node, settings):
91-
wx.Window.__init__(self, tree.GetParent())
9291
self.controller = controller
9392
self._tree = tree
9493
self._node = node
9594
self._settings = settings
9695
self._rendered = False
97-
self.Show(False)
9896
self._popup_creator = tree._popup_creator
9997

10098
@property
@@ -106,7 +104,7 @@ def node(self):
106104
return self._node
107105

108106
def show_popup(self):
109-
self._popup_creator.show(self, PopupMenuItems(self, self._actions),
107+
self._popup_creator.show(self._tree, PopupMenuItems(self, self._actions),
110108
self.controller)
111109

112110
def begin_label_edit(self):
@@ -559,7 +557,7 @@ def _add_copy_to_tree(self, parent_node, copied):
559557
def _create_rename_command(self, new_name):
560558
return RenameKeywordOccurrences(
561559
self.controller.name, new_name,
562-
RenameProgressObserver(self.GetParent().GetParent()),
560+
RenameProgressObserver(self._tree.GetParent()),
563561
self.controller.info)
564562

565563
def OnFindUsages(self, event):
@@ -603,7 +601,7 @@ def item(self):
603601

604602
def OnAddResource(self, event):
605603
path = RobotFilePathDialog(
606-
self, self.controller, self._settings).execute()
604+
self._tree, self.controller, self._settings).execute()
607605
if path:
608606
self.controller.load_resource(path, LoadProgressObserver(self))
609607

src/robotide/widgets/popupmenu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ def __init__(self, parent, menu_items):
5454
if item.is_separator():
5555
self.AppendSeparator()
5656
else:
57-
self._add_item(parent, item)
57+
self._add_item(item)
5858
parent.PopupMenu(self)
5959
self.Destroy()
6060

61-
def _add_item(self, parent, item):
61+
def _add_item(self, item):
6262
id_ = wx.NewIdRef()
6363
self.Append(id_, item.name)
64-
parent.Bind(wx.EVT_MENU, item.callable, id=id_)
64+
self.Bind(wx.EVT_MENU, item.callable, id=id_)
6565

6666

6767
class PopupMenuItems(object):

0 commit comments

Comments
 (0)