Vector35 / Vector35/binaryninja-api

Document python ui code pitfalls

Open
#6,870 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Effort: Low Impact: Low
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

Namely that you have to hold references to intermediate objects, so instead of

import binaryninjaui
print(binaryninjaui.UIContext.activeContext().getCurrentView().actionContext().token.token)

you have to do

import binaryninjaui
ui_context = binaryninjaui.UIContext.activeContext()
view = ui_context.getCurrentView()
action_context = view.actionContext()
token = action_context.token
print(token.token)

See also: https://doc.qt.io/qtforpython-6/shiboken6/typesystem_ownership.html#not-saving-unowned-objects-references

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Python UI documentation in this repository and review the linked Qt for Python ownership guidance. Document the need to retain intermediate UI objects, using the issue's two examples, so readers can avoid the chained-call pitfall.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.