nodeview: fixed crash when expanding a NodeViewItem with a NodeInputArray
This commit is contained in:
@@ -56,10 +56,10 @@ NodeEdgePtr NodeViewEdge::edge()
|
||||
return edge_;
|
||||
}
|
||||
|
||||
qreal CalculateEdgeYPoint(NodeViewItem *item, int param_index, NodeViewItem *opposing)
|
||||
qreal CalculateEdgeYPoint(NodeViewItem *item, NodeParam* param, NodeViewItem *opposing)
|
||||
{
|
||||
if (item->IsExpanded()) {
|
||||
return item->pos().y() + item->GetParameterConnectorRect(param_index).center().y();
|
||||
return item->pos().y() + item->GetParameterConnectorRect(param).center().y();
|
||||
} else {
|
||||
qreal max_height = qMax(opposing->rect().height(), item->rect().height());
|
||||
|
||||
@@ -89,8 +89,8 @@ void NodeViewEdge::Adjust()
|
||||
QPointF input_point = QPointF(input->pos().x() + output->rect().left(), 0);
|
||||
|
||||
// Calculate output/input points
|
||||
output_point.setY(CalculateEdgeYPoint(output, edge_->output()->index(), input));
|
||||
input_point.setY(CalculateEdgeYPoint(input, edge_->input()->index(), output));
|
||||
output_point.setY(CalculateEdgeYPoint(output, edge_->output(), input));
|
||||
input_point.setY(CalculateEdgeYPoint(input, edge_->input(), output));
|
||||
|
||||
// Draw a line between the two
|
||||
setLine(QLineF(
|
||||
|
||||
@@ -154,6 +154,18 @@ QRectF NodeViewItem::GetParameterConnectorRect(int index)
|
||||
return connector_rect;
|
||||
}
|
||||
|
||||
QRectF NodeViewItem::GetParameterConnectorRect(NodeParam *param)
|
||||
{
|
||||
NodeParam* root_param = param;
|
||||
Node* parent_node = param->parentNode();
|
||||
|
||||
while (root_param->parent() != parent_node) {
|
||||
root_param = static_cast<NodeParam*>(root_param->parent());
|
||||
}
|
||||
|
||||
return GetParameterConnectorRect(root_param->index());
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::GetParameterTextPoint(int index)
|
||||
{
|
||||
if (node_ == nullptr) {
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
* Index of the parameter of this node (see NodeParam::index()).
|
||||
*/
|
||||
QRectF GetParameterConnectorRect(int index);
|
||||
QRectF GetParameterConnectorRect(NodeParam* index);
|
||||
|
||||
protected:
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
Reference in New Issue
Block a user