Skip to content

fix: modifying waypoints for a group layer no longer modifies sibling layers - #3312

Merged
rodolforg merged 1 commit into
synfig:masterfrom
mosasauridae:group-waypoint-fix
Apr 21, 2025
Merged

rodolforg merged 1 commit into
synfig:masterfrom
mosasauridae:group-waypoint-fix

Conversation

@mosasauridae

Copy link
Copy Markdown
Contributor

When a group layer is selected, the time track will show waypoints for child layers in the group. Modifying one of these waypoints (remove, move, or duplicate) was also pulling in waypoints of sibling layers of the group, not just child layers, if the sibling also happened to have a waypoint at the same time.

Reproduction steps:

  1. Create 2 circle layers, and animate the location of both circles so that both have waypoints on the same frame
  2. Put one of the circles into a group layer
  3. Select the group layer, and right click a waypoint in the time track. Note that it says "Remove 2 Waypoints", even though there's only one layer in the group
  4. Select Remove. Both circle layers are modified, even though only one of them is in the selected group.

I'm still a bit fuzzy on the relationship between canvases and group layers. I tested that waypoints for imported files still works, but I don't know if there's another way to create a canvas object that would need to be tested as well.

@rodolforg

rodolforg commented Jan 20, 2024 •

Copy link
Copy Markdown
Contributor

Nice bug catch!

I'm still a bit fuzzy on the relationship between canvases and group layers.

Group, Switch group and Filter group are all layers that show an encapsulated canvas (that has one or more stacked layers). Code-wise they are all derived from Layer_PasteCanvas. The encapsulated canvas is referred in their parameter "canvas".

About your code, I don't if it's preferred to inspect the canvas node (value_desc.get_layer()->get_param(value_desc.get_param_name()).get(synfig::Canvas::Handle());) or its layer owner as you proposed.

@mosasauridae

Copy link
Copy Markdown
Contributor Author

That makes sense. I'll try it with your suggestion, definitely seems like the logic is clearer if the canvas parameter is inspected instead of the layer itself.

@mosasauridae

Copy link
Copy Markdown
Contributor Author

About your code, I don't if it's preferred to inspect the canvas node (value_desc.get_layer()->get_param(value_desc.get_param_name()).get(synfig::Canvas::Handle());) or its layer owner as you proposed.

Both versions seemed to work for me at first so I did some more digging, and found something interesting - my first version with node = value_desc.get_layer() would have actually introduced a bug. If the group layer defines a non-zero Time Offset parameter, then passing in the layer rather than the canvas node causes synfig::waypoint_collect to search at the wrong time point, missing the waypoints that the user clicked (waypoint_collect has special logic for Layer_PasteCanvas to account for the offset, but that logic shouldn't run in this specific case).

I updated it to use the canvas node and did some testing with Time Offsets to make sure that was all still working.

@mosasauridae
mosasauridae deleted the group-waypoint-fix branch April 17, 2025 03:14
@rodolforg

Copy link
Copy Markdown
Contributor

Hi, @mosasauridae . Why did you close this PR?

@mosasauridae

Copy link
Copy Markdown
Contributor Author

I was cleaning out some old branches in my repo and deleted the branch associated with this PR. I figured it'd been pocket-vetoed after over a year with no activity, and wasn't needed.

I can restore the branch if there's still interest in this change. And if there's anything else that would need to go with this (ie creating an issue for it) I can do that as well.

@rodolforg

Copy link
Copy Markdown
Contributor

It wasn't vetoed :) I just asked you a small change before we merge it ;)
Please restore the branch and, if possible, change the commit to something like:

		else if (value_desc.parent_is_layer()) {
			const auto value = value_desc.get_layer()->get_param(value_desc.get_param_name());
			if (value.get_type() == synfig::type_canvas)
				node = value.get(synfig::Canvas::Handle());
		}

@mosasauridae

Copy link
Copy Markdown
Contributor Author

Ohh I'm sorry I didn't realize I had more changes, I thought it was good to go after the first update. I'll restore the branch.

@mosasauridae
mosasauridae restored the group-waypoint-fix branch April 19, 2025 15:43
@mosasauridae mosasauridae reopened this Apr 19, 2025
@mosasauridae
mosasauridae force-pushed the group-waypoint-fix branch 2 times, most recently from 1d5883f to 02b1c80 Compare April 19, 2025 16:30
rodolforg
rodolforg previously approved these changes Apr 19, 2025
@rodolforg

Copy link
Copy Markdown
Contributor

Sorry, @mosasauridae , but I have one more request XD

We're trying to keep a consistent code style for a while now, but we're applying it to new code and to lines we change when creating new PRs.

In this case:

  1. opening curly brackets { for if, else, for, while, and do` must be in the same line of those tokens.
  2. We balance if branches: if the if or the else branch needs to use curly brackets {} in its contents, the other one must use them too.

So, please change to:

if (condition) {
	// stuff
} else {
	// more stuff
	// and more
}

@mosasauridae

Copy link
Copy Markdown
Contributor Author

@rodolforg No worries, makes sense

@rodolforg
rodolforg merged commit ae97e0f into synfig:master Apr 21, 2025
@rodolforg

Copy link
Copy Markdown
Contributor

Merged.
Thank you for contributing!

@mosasauridae
mosasauridae deleted the group-waypoint-fix branch May 15, 2025 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants