binaryninja-api
binaryninja-api copied to clipboard
Document python ui code pitfalls
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