Skip to content

Graph corruption #21

Description

@khalimwu

More than once i'm getting data from an old graph setting. For example if at some past moment i had 2 nodes in a random future day i get corruption due to a node being null. (only 1 node is really present on the graph but 2 nodes are present internally, only 1 being valid and the other being a null pointer). The issue is fixed forcing save, however it has happened to me that even then, after a couple days, the blueprint is corrupted again.

Probably the most important change is this one where i do check if an edge was already present

`bool UAssetGraphSchema_GenericGraph::CreateAutomaticConversionNodeAndConnections(UEdGraphPin* A, UEdGraphPin* B) const
{
UEdNode_GenericGraphNode* NodeA = Cast<UEdNode_GenericGraphNode>(A->GetOwningNode());
UEdNode_GenericGraphNode* NodeB = Cast<UEdNode_GenericGraphNode>(B->GetOwningNode());

// Are nodes and pins all valid?
if (!NodeA || !NodeA->GetOutputPin() || !NodeB || !NodeB->GetInputPin())
	return false;
	
// My code: if we are creating a connection between two nodes that already got a connection, skip it.
if ( A->Direction == EGPD_Output )
{
	if ( NodeA->GenericGraphNode &&
		 NodeA->GenericGraphNode->GetEdge( NodeB->GenericGraphNode ) )
		return false;
}
else
{
	if ( NodeB->GenericGraphNode &&
		 NodeB->GenericGraphNode->GetEdge( NodeA->GenericGraphNode ) )
		return false;
}
//

UGenericGraph* Graph = NodeA->GenericGraphNode->GetGraph();

FVector2D InitPos((NodeA->NodePosX + NodeB->NodePosX) / 2, (NodeA->NodePosY + NodeB->NodePosY) / 2);

FAssetSchemaAction_GenericGraph_NewEdge Action;
Action.NodeTemplate = NewObject<UEdNode_GenericGraphEdge>(NodeA->GetGraph());
Action.NodeTemplate->SetEdge(NewObject<UGenericGraphEdge>(Action.NodeTemplate, Graph->EdgeType));
UEdNode_GenericGraphEdge* EdgeNode = Cast<UEdNode_GenericGraphEdge>(Action.PerformAction(NodeA->GetGraph(), nullptr, InitPos, false));

// Always create connections from node A to B, don't allow adding in reverse
EdgeNode->CreateConnections(NodeA, NodeB);

return true;

}`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions