Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ListAttributes identically when removing edges or nodes #2280

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

cbentejac
Copy link
Contributor

Description

The behaviour regarding ListAttributes was different depending on whether an edge or a node was removed:

  • if an edge was removed, the ListAttribute that was the destination of that edge had its corresponding element completely removed;
  • if a node was removed, the ListAttribute that was the destination of one of the node's edges had its corresponding element reset, but not removed.

With this behaviour, a user had different UIDs depending on whether a single edge or the whole node had been removed where the UID should always be identical.

This PR ensures that removing a node has the same effect on a connected node as removing an edge: it thus removes completely an element connected to a ListAttribute when the node is removed.

Implementation remarks

When collecting the outgoing edges, we now check whether the edge is connected to a ListAttribute. If it is, we associate the attribute of the outgoing edge to a tuple containing the ListAttribute it is connected to and its value (if it has any). We then remove the corresponding element in the ListAttribute the edge is connected to.

When recreating a node that has been removed (either by performing an "Undo" action or by upgrading a node), this map is used to check whether the edge that will be re-added is to be connected to a ListAttribute. If it is, a new element is added to the ListAttribute with the value stored in the map. Re-creating the entry in the list is necessary: if it does not exist, the edge will not have any destination attribute to connect to.

meshroom/core/graph.py Outdated Show resolved Hide resolved
Copy link
Member

@fabiencastan fabiencastan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to preserve index in lists during undo

@cbentejac cbentejac force-pushed the fix/removeEdges branch 2 times, most recently from 0829252 to 6a01610 Compare January 19, 2024 16:30
The behaviour regarding `ListAttributes` was different depending on
whether an edge or a node was removed:
- if an edge was removed, the `ListAttribute` that was the destination
of that edge had its corresponding element completely removed;
- if a node was removed, the `ListAttribute` that was the destination
of one of the node's edges had its corresponding element reset, but not
removed.

With this behaviour, a user had different UIDs depending on whether
a single edge or the whole node had been removed where the UID should
always be identical.
@fabiencastan fabiencastan merged commit c2ac214 into develop Feb 5, 2024
4 checks passed
@fabiencastan fabiencastan deleted the fix/removeEdges branch February 5, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants