diff --git a/src/widgets/GraphGridLayout.cpp b/src/widgets/GraphGridLayout.cpp index b3b6848a..5766e1fd 100644 --- a/src/widgets/GraphGridLayout.cpp +++ b/src/widgets/GraphGridLayout.cpp @@ -123,6 +123,10 @@ void GraphGridLayout::CalculateLayout(std::unordered_map &bloc auto block_order = topoSort(layoutState, entry); computeBlockPlacement(entry, layoutState); + for (auto &blockIt : blocks) { + layoutState.edge[blockIt.first].resize(blockIt.second.edges.size()); + } + // Prepare edge routing auto &entryb = layoutState.grid_blocks[entry]; EdgesVector horiz_edges, vert_edges; @@ -145,9 +149,10 @@ void GraphGridLayout::CalculateLayout(std::unordered_map &bloc for (ut64 blockId : block_order) { GraphBlock &block = blocks[blockId]; GridBlock &start = layoutState.grid_blocks[blockId]; + size_t i = 0; for (const auto &edge : block.edges) { GridBlock &end = layoutState.grid_blocks[edge.target]; - layoutState.edge[blockId].push_back(routeEdge(horiz_edges, vert_edges, edge_valid, start, end)); + layoutState.edge[blockId][i++] = routeEdge(horiz_edges, vert_edges, edge_valid, start, end); } } @@ -237,6 +242,10 @@ void GraphGridLayout::CalculateLayout(std::unordered_map &bloc size_t index = 0; assert(block.edges.size() == layoutState.edge[block.entry].size()); for (GridEdge &edge : layoutState.edge[block.entry]) { + if (edge.points.empty()) { + qDebug() << "Warning, unrouted edge."; + continue; + } auto start = edge.points[0]; auto start_col = start.col; auto last_index = edge.start_index; diff --git a/src/widgets/GraphView.cpp b/src/widgets/GraphView.cpp index f9a6462d..edf00308 100644 --- a/src/widgets/GraphView.cpp +++ b/src/widgets/GraphView.cpp @@ -158,6 +158,9 @@ void GraphView::paintEvent(QPaintEvent *event) // TODO: Only draw edges if they are actually visible ... // Draw edges for (GraphEdge &edge : block.edges) { + if (edge.polyline.empty()) { + continue; + } QPolygonF polyline = recalculatePolygon(edge.polyline); EdgeConfiguration ec = edgeConfiguration(block, &blocks[edge.target]); QPen pen(ec.color);