Skip to content
Snippets Groups Projects
Commit 4c2efe73 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Fixed a bug when removing a point from an EditorLine that could lead to a crash.

parent dd9fc9f5
No related branches found
No related tags found
No related merge requests found
......@@ -224,6 +224,7 @@ void UGPUInstancedLineComponent::PostInitProperties()
UE_LOG(LogTemp, Display, TEXT("UGPUInstancedLineComponent::PostInitProperties IF"));
}
//#pragma optimize("", off)
#if WITH_EDITOR
void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent)
......@@ -291,22 +292,22 @@ void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedCha
{
// Get Indices
const int32 RemovedAtIndex = PropertyChangedEvent.GetArrayIndex(PropertyChangedEvent.Property->GetFName().ToString());
const int32 LineIndex = PropertyChangedEvent.GetArrayIndex(PropertyChangedEvent.PropertyChain.GetActiveNode()->GetPrevNode()->GetValue()->GetFName().ToString());
const int32 EditorLineIndex = PropertyChangedEvent.GetArrayIndex(PropertyChangedEvent.PropertyChain.GetActiveNode()->GetPrevNode()->GetValue()->GetFName().ToString());
check(RemovedAtIndex != INDEX_NONE);
check(LineIndex != INDEX_NONE);
check(EditorLineIndex != INDEX_NONE);
// This isn't allowed to happen, but cannot be explicitly forbidden in the engine. For now, just hack it by inserting a point at 0,0,0.
// Alternatively, just delete the line? TODO
if(EditorLines[LineIndex].Points.Num() < 2)
if(EditorLines[EditorLineIndex].Points.Num() < 2)
{
UE_LOG(LogTemp, Error, TEXT("UGPUInstancedLineComponent: A Line needs to consist of at least two points, trying to remove one of them doesn't work. Defaulted point inserted again!"));
EditorLines[LineIndex].Points.AddZeroed(1);
UpdatePoint(EditorLines[LineIndex].RespectiveLineId, RemovedAtIndex, EditorLines[LineIndex].Points[RemovedAtIndex].Point);
EditorLines[EditorLineIndex].Points.AddZeroed(1);
UpdatePoint(EditorLines[EditorLineIndex].RespectiveLineId, RemovedAtIndex, EditorLines[EditorLineIndex].Points[RemovedAtIndex].Point);
}
else
{
RemovePoint(LineIndex, RemovedAtIndex);
RemovePoint(EditorLines[EditorLineIndex].RespectiveLineId, RemovedAtIndex);
}
}
......@@ -396,6 +397,7 @@ void UGPUInstancedLineComponent::PostEditChangeProperty(FPropertyChangedEvent& P
Super::PostEditChangeProperty(PropertyChangedEvent);
}
#endif
//#pragma optimize("", on)
// Doesn't do anything yet, just as a testing function to see execution order on Unreal startup.
void UGPUInstancedLineComponent::PostLoad()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment