bugfix: issue where adding direction to new node was segfaulting

This commit is contained in:
Matthew Kosarek 2023-12-15 16:54:40 -05:00
parent 3cec993799
commit 5bc1830c56
2 changed files with 3 additions and 2 deletions

View File

@ -320,6 +320,7 @@ bool Node::move_node(int from, int to) {
void Node::insert_node(std::shared_ptr<Node> node, int index)
{
auto position = new_node_position(index);
node->parent = shared_from_this();
node->set_rectangle(position);
sub_nodes.insert(sub_nodes.begin() + index, node);
}

View File

@ -179,13 +179,13 @@ bool WindowTree::try_move_active_window(miracle::WindowMoveDirection direction)
// get inserted into the parent node at the index before
// the currently active lane.
auto node_to_move = active_lane->get_sub_nodes()[node_index];
advise_delete_window(node_to_move->get_window());
int active_lane_index = 0;
for (; active_lane_index < parent->get_sub_nodes().size(); active_lane_index++)
if (parent->get_sub_nodes()[active_lane_index] == active_lane)
break;
advise_delete_window(node_to_move->get_window());
parent->insert_node(node_to_move, active_lane_index);
active_lane = parent;
}
@ -203,13 +203,13 @@ bool WindowTree::try_move_active_window(miracle::WindowMoveDirection direction)
// get inserted into the parent node at the index before
// the currently active lane.
auto node_to_move = active_lane->get_sub_nodes()[node_index];
advise_delete_window(node_to_move->get_window());
int active_lane_index = 0;
for (; active_lane_index < parent->get_sub_nodes().size(); active_lane_index++)
if (parent->get_sub_nodes()[active_lane_index] == active_lane)
break;
advise_delete_window(node_to_move->get_window());
parent->insert_node(node_to_move, active_lane_index + 1);
active_lane = parent;
}