rizinorg/cutter

DissasemblyContextMenu action hiding logic causes problems

Open

#1,733 opened on Sep 2, 2019

View on GitHub
 (5 comments) (1 reaction) (0 assignees)C++ (14,852 stars) (1,123 forks)batch import
BUGHacktoberFestgood first issue

Description

Environment information

  • Operating System: ArchLinux
  • Cutter version: 81f71693795ff97ae32c15635796e26335376349
  • File format:

Describe the bug

Some of the actions in disassembly context menu are hidden when not applicable. This is done by performing the check in aboutToShowSlot. Action stays hidden the next time context menu is opened. Hiding action also disables it making it impossible to call it using shortcut. This means that after right clicking on a place where action isn't applicable shortcut gets disabled even after changing offset to position where action is applicable.

To Reproduce

In disassembly widget

  • Right click on function header, observe that menu contains "Rename funciton fcn.0x123456 N" action
  • Press "N" and observe that shortcut works
  • Right click second instruction in function, observe that "Rename function" action is hidden
  • Left click on function header
  • Try pressing "N" shortcut for renaming function and observe that it doesn't work anymore

Expected behavior

In the last step of instructions above "N" shortcut works.

Rename function is just an exmaple, there might be other actions in disassembly context menu affected by the same problem.

Possible solutions

A) Update action status in setOffset function. Downside that it causes a bunch of unnecessary r2 queries while navigating disassembly widget. Probably not a problem, at least for small binaries.

B)

  • keep conditional hiding in aboutToShowSlot
  • in setOffset or reenable the actions
  • in the action callback check if it is applicable

Solution b is slightly more efficient but complicated. Step 1 and sometimes 3 are already implemented so it might not be so

Additional context

This problem applies only to actions that get conditionally hidden and have keyboard shortcut.

Contributor guide

DissasemblyContextMenu action hiding logic causes problems · rizinorg/cutter#1733 | Good First Issue