FlowGraph icon indicating copy to clipboard operation
FlowGraph copied to clipboard

Error in Copy/Paste node

Open likemango opened this issue 1 year ago • 2 comments

When I select a group of nodes including StartNode which can't be duplicated, then, I can paste those group of nodes. Now, StartNode been duplicated couldn't be deleted, get mess on the graph. image

likemango avatar May 17 '24 01:05 likemango

I did some investigation of this issue and found the root of it. When copying selected nodes, editor allows to copy nodes if any of the nodes can be duplicated/copied. Actual checking for each node is located inside FCustomizableTextObjectFactory::ProcessBuffer. It takes node's class, then its CDO and call CanDuplicateNode(). If we look into UFlowGraphNode's implementation of CanDuplicateNode(), we will see that it requires FlowNode instance to be set, and CDO do not have it, therefore for CDO this function will always return true. image_2024-05-18_16-23-41

I came up to 4 possible solutions to this issue:

  1. (Preffered by me as a general case) Filter out nodes, which can't be duplicated, in CopySelectedNodes. Working example: image_2024-05-18_16-23-41 (3)

  2. (Only applicable to Start node) Automaticaly replace Start node to CustomInput node. It would be similar behaviour to copying CustomEvent nodes in Blueprints.

  3. Modify UFlowGraphNode::CanDuplicateNode to take into account AssignedNodeClasses. It would be perfectly fine in case of single element in AssignedNodeClasses, but what if there are two classes and each have different bCanDuplicate value? Working(?) example: image_2024-05-18_16-23-41 (2)

  4. Store bCanDuplicate directly in UFlowGraphNode. This is not very flexible as for noncopyable custom UFlowNode user would have to specify special UFlowGraphNode with bCanDuplicate == false.

I don't know which fix would be better fit (maybe something else), so leave it to @MothDoctor to decide.

MaksymKapelianovych avatar May 18 '24 13:05 MaksymKapelianovych

Thanks, you have a great ideas to solve this problem, I gonna try those.

likemango avatar May 18 '24 13:05 likemango

Hey @MaksymKapelianovych thanks for investigating this issue.

I went with option 4 (slightly adjusted after testing) since I assume that the editor code should know about the specializations of specific nodes. And yes, usually Flow Node class doesn't disable duplicating. It only occurs for super specific nodes like "Start", so this solution shouldn't cause issues :)

MothDoctor avatar Dec 15 '24 18:12 MothDoctor