Vector35 / Vector35/binaryninja-api

Allow for FlowGraphWidget to not have a backing view or function

Open
#4,764 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
Currently, FlowGraph::Show is very limited in terms of cutomization since we don't have access to the underlying QWidget. There is a FlowGraphWidget type available that allow for more control, but it seems it requires to have a backing function. It seems there is tight coupling between the Function type and the FlowGraphWidget rendering. Some checks are performed within the FlowGraphWidget::paintEvent function which disallow custom FlowGraphWidget. More information can be found in this thread.

Is your feature request related to a problem?
I am trying to develop a specific plugin to display structured information, but not disassembly. It is required to have more control over the widget for UX reasons. But so far nothing in the current public API seems to work. A simple example demonstrating the issue can be reproduced using this snippet:

void TestFlowGraph(bn::Ref<bn::BinaryView> view) {
  bn::FlowGraph* graph = new bn::FlowGraph();
  auto* node = new bn::FlowGraphNode(graph);

  bn::DisassemblyTextLine line{};
  line.tokens.push_back(bn::InstructionTextToken{InstructionToken, "test"});
  line.addr = 0;

  std::vector<bn::DisassemblyTextLine> lines{};
  lines.push_back(line);

  node->SetLines(lines);
  graph->AddNode(node);
  //graph->Show("asdf"); // This works

  auto view_context = UIContext::activeContext();

  FlowGraphWidget* widget = new FlowGraphWidget{nullptr, view, graph};
  //CustomFlowGraphWidget* widget =
  //    new CustomFlowGraphWidget{nullptr, view, graph};
  widget->setGraph(graph);
  //widget->updateToGraph(graph);
  auto* pane = new WidgetPane(widget, "asdf");
  view_context->openPane(pane); // This will display "Loading..."
  // widget->show();
  //  We leak, we don't care for now
}

The current snippet will open a window that displays Loading....

Are any alternative solutions acceptable?
A sufficient option would be to have the exact same FlowGraphWidget type with all the functions related checks removed. We could call it CustomFlowGraphWidget.

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 with FlowGraphWidget::paintEvent and the construction, setGraph, and updateToGraph calls shown in the reproduction, then compare them with FlowGraph::Show. Trace the Function and backing-view checks that lead to “Loading...” and determine the supported customization boundary. Done means a FlowGraphWidget or equivalent custom widget can display a graph without those required dependencies while preserving normal FlowGraph::Show behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.