MothCocoon / FlowGraph

Design-agnostic node system for scripting game’s flow in Unreal Engine

Home Page:https://discord.gg/Xmtr6GhbmW

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash when creating a new node from pin

Adrien-Lucas opened this issue · comments

Hi Doctor!

It's been some times I was having a crash when dragging from a flow pin, then making a new node from it.
I finally took time to investigate this and found where the error came.

In your AutowireNewNode func (FlowGraphNode.cpp), at some point, the OwningNode of the FromPin gets obliterated.
It happens in the "TryCreateConnection(FromPin, Pin)" of the if statement.

After investigating, it turns out that the TryCreateConnection notifies the graph of a change, without any change having really applied yet.
I haven't looked at who is subscribed to this event, but for some reason, notifying in the middle of the Autowire process breaks a reference.

My fix for the moment was to simply remove the notify.

bool UFlowGraphSchema::TryCreateConnection(UEdGraphPin* PinA, UEdGraphPin* PinB) const
{
	const bool bModified = UEdGraphSchema::TryCreateConnection(PinA, PinB);

	if (bModified)
	{
		//PinA->GetOwningNode()->GetGraph()->NotifyGraphChanged();
	}

	return bModified;
}

But I guess the right way would be to still notify the graph, but after the autowire process.

I hope this can help!

@MrBrenan I tried, but cannot reproduce this crash. Is there any specific repro for that?

Theoretically, Owning Node cannot be invalidated why operating on its pin. Yeah, it could cause a lot of crashes. Do you use here your own node spawner class or other editor code?

Didn't receive a repro in 3 weeks, so closing this ticket.