The editor crashes when modifying a Lighting Channels checkbox through the Generic Object Mixer.
The crash occurs inside:
FLightingChannelsCustomization::OnButtonCheckedStateChanged()
with the assertion:
Assertion failed: IsValid()
[File: Runtime/Core/Public/Templates/SharedPointer.h]
[Line: 1133]
The issue appears to be caused by GetChildHandle() returning a valid handle before SetValue(), but returning an invalid handle immediately afterward. The current implementation retrieves the child handle multiple times and dereferences the second handle without validating it.
Reproduction Steps
- Open a level containing a StaticMeshComponent.
- Open Window → Light Mixer → Open Generic Object Mixer Instance.
- Add a filter that exposes a StaticMeshComponent.
- Add the Lighting Channels property column.
- Toggle one of the Lighting Channel checkboxes.
Currently I have stored the ChildHandle before SetValue and That prevent unreal editor crashing, hopefully this can be fix in the next patch before unreal 6.0
void FLightingChannelsCustomization::OnButtonCheckedStateChanged(ECheckBoxState NewState, uint32 ChildIndex) const
{
if (LightingChannelsHandle.IsValid())
{
uint32 OutNumChildren = 0;
LightingChannelsHandle->GetNumChildren(OutNumChildren);
if (ChildIndex < OutNumChildren)
{
/*
LightingChannelsHandle->GetChildHandle(ChildIndex)->SetValue(NewState == ECheckBoxState::Checked);
LightingChannelsHandle->GetChildHandle(ChildIndex)->NotifyFinishedChangingProperties();
LightingChannelsHandle->NotifyFinishedChangingProperties();
*/
/*
auto ChildHandleA = LightingChannelsHandle->GetChildHandle(ChildIndex);
UE_LOG(LogTemp, Warning, TEXT("Handle A valid=%d"), ChildHandleA.IsValid());
ChildHandleA->SetValue(NewState == ECheckBoxState::Checked);
auto ChildHandleB = LightingChannelsHandle->GetChildHandle(ChildIndex);
UE_LOG(LogTemp, Warning, TEXT("Handle B valid=%d"), ChildHandleB.IsValid());
ChildHandleB->NotifyFinishedChangingProperties();
*/
TSharedPtr<IPropertyHandle> ChildHandle = LightingChannelsHandle->GetChildHandle(ChildIndex);
FPropertyAccess::Result Result = ChildHandle->SetValue(NewState == ECheckBoxState::Checked);
UE_LOG(LogTemp, Warning, TEXT("SetValue completed"));
ChildHandle->NotifyFinishedChangingProperties();
UE_LOG(LogTemp, Warning, TEXT("ChildHandle NotifyFinishedChangingProperties completed"));
LightingChannelsHandle->NotifyFinishedChangingProperties();
UE_LOG(LogTemp, Warning, TEXT("LightingChannelsHandle NotifyFinishedChangingProperties completed"));
}
}
}