Skip to content

Commit

Permalink
Bug fixes: UI and graphs
Browse files Browse the repository at this point in the history
Update some old APIs:

- ctx.form_type -> ctx.widget_type
- nx.DiGraph.node -> nx.DiGraph.nodes

This fixes both the xrefsgraph and the autoenum plugins.
  • Loading branch information
tmr232 committed Mar 18, 2022
1 parent 32e801d commit bb43611
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions plugins/autoenum.py
Expand Up @@ -78,7 +78,7 @@ def activate(self, ctx):
return 1

def update(self, ctx):
if ctx.form_type == idaapi.BWN_DISASM:
if ctx.widget_type == idaapi.BWN_DISASM:
return idaapi.AST_ENABLE_FOR_WIDGET
return idaapi.AST_DISABLE_FOR_WIDGET

Expand All @@ -94,7 +94,7 @@ def activate(self, ctx):
return 1

def update(self, ctx):
if ctx.form_type == idaapi.BWN_DISASM:
if ctx.widget_type == idaapi.BWN_DISASM:
return idaapi.AST_ENABLE_FOR_WIDGET
return idaapi.AST_DISABLE_FOR_WIDGET

Expand Down
2 changes: 1 addition & 1 deletion plugins/xrefsgraph.py
Expand Up @@ -87,7 +87,7 @@ def show_xref_graph(ea, to=False, distance=4):

call_graph = gen_xref_graph(ea, to=to, distance=distance)

call_graph.node[ea][sark.ui.NXGraph.BG_COLOR] = 0x80
call_graph.nodes[ea][sark.ui.NXGraph.BG_COLOR] = 0x80

title = 'Xrefs {tofrom} {target} '.format(tofrom='to' if to else 'from',
target=_get_best_name(ea))
Expand Down
4 changes: 2 additions & 2 deletions sark/ui.py
Expand Up @@ -175,7 +175,7 @@ class NXGraph(idaapi.GraphViewer):
1. By specifying the `handler` parameter to the constructor;
2. By setting the `NXGraph.HANDLER` attribute of a specific node:
>>> my_graph.node[my_node][NXGraph.HANDLER] = MyCustomHandler()
>>> my_graph.nodes[my_node][NXGraph.HANDLER] = MyCustomHandler()
Two other useful attribute are `NXGraph.BG_COLOR` and `NXGraph.FRAME_COLOR` that allow
specifying colors for your nodes. If not provided, the default color will be used.
Expand Down Expand Up @@ -271,7 +271,7 @@ def _get_handler(self, node_id):

def _get_attrs(self, node_id):
"""Get the node's attributes"""
return self._graph.node[self[node_id]]
return self._graph.nodes[self[node_id]]

def _get_handling_triplet(self, node_id):
"""_get_handling_triplet(node_id) -> (handler, value, attrs)"""
Expand Down

0 comments on commit bb43611

Please sign in to comment.