Repository navigation
Conversation
When copying and pasting skeleton layers, the bone links were not properly updated to point to the new cloned bones. This caused the pasted skeleton to reference bones from the original layer instead of its own bones. This fix: - Adds get_special_layer_valuenodes() to collect skeleton bone valuenodes - Adds replace_skeleton_valuenodes() to fix bone links in pasted layers - Updates paste() to collect layer mappings and apply skeleton fixes Fixes synfig#453
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug where copying and pasting skeleton layers resulted in incorrect bone references. The solution integrates robust remapping logic into the paste operation, ensuring that cloned skeleton layers correctly link to their own newly created bones, thereby maintaining animation integrity across duplicated content. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly applies the logic from LayerDuplicate to the copy-paste functionality to fix skeleton bone links. The changes are well-structured and follow the approach of the existing code. I've identified a potential crash due to an unchecked map lookup and a minor performance improvement opportunity in a lambda capture. Overall, this is a good fix that addresses the reported issue.
| { | ||
| std::vector<ValueNode::RHandle> valuenodes; | ||
| if (layer->get_name() == "duplicate") { | ||
| valuenodes.push_back(layer->dynamic_param_list().find("index")->second); |
There was a problem hiding this comment.
The call to layer->dynamic_param_list().find("index") may return an iterator to the end of the map if "index" is not found. Dereferencing this iterator to access ->second would result in undefined behavior, likely a crash. You should add a check to ensure the iterator is valid before dereferencing it.
A similar issue might exist in synfigapp/actions/layerduplicate.cpp from where this code was copied.
auto it = layer->dynamic_param_list().find("index");
if (it != layer->dynamic_param_list().end()) {
valuenodes.push_back(it->second);
}| for (const auto& layer_pair : cloned_layer_map) { | ||
| auto cloned_layer = layer_pair.second; | ||
| replace_value_nodes(cloned_layer, | ||
| [cloned_valuenode_map](ValueNode::LooseHandle vn) -> ValueNode::LooseHandle { |
There was a problem hiding this comment.
The lambda captures cloned_valuenode_map by copy, which can be inefficient if the map is large. Since the map is not modified within the lambda, it's better to capture it by reference (&) to avoid an unnecessary copy.
A similar issue might exist in synfigapp/actions/layerduplicate.cpp.
[&cloned_valuenode_map](ValueNode::LooseHandle vn) -> ValueNode::LooseHandle {|
Hi there! 👋 I noticed that this PR fixes issue #453, which had a $60 bounty on Bountysource. Since Bountysource has unfortunately shut down and filed for bankruptcy, I was wondering if there's an alternative way to claim this bounty? Thank you for your time and for maintaining this wonderful project! 🙏 |
Continuation of locky504's open PR synfig#3702 at head 242e652: pasting a nested skeleton no longer drops the inner structure.
Problem
When copying and pasting skeleton layers, the bone links were not properly updated to point to the new cloned bones. This caused the pasted skeleton to reference bones from the original layer instead of its own bones.
This fixes issue #453.
Root Cause
The
paste()function inLayerActionManagerwas only doing a simpleclone()of layers without fixing the special valuenodes that skeleton layers use for bone references.The
LayerDuplicateaction already had this fix, but the copy-paste functionality (Ctrl+C/Ctrl+V) was missing it.Solution
Applied the same skeleton fix logic from
LayerDuplicate::prepare()toLayerActionManager::paste():get_special_layer_valuenodes()- Collects skeleton bone valuenodes that need to be remappedreplace_skeleton_valuenodes()- Fixes bone links in pasted layers to point to the correct (new) bonespaste()- Now collects layer mappings and applies skeleton fixes after all layers are pastedChanges
synfig-studio/src/gui/actionmanagers/layeractionmanager.cppsynfigapp/actions/layerduplicate.cppTesting
LayerDuplicateskeleton testsBounty
This PR fixes issue #453 which has a $60 bounty on Bountysource.