In Engine/Source/Editor/UnrealEd/Private/Factories/EditorFactories.cpp from 3571 to 3586.
if ( PngImageWrapper->GetRaw( Format, BitDepth, RawPNG ) )
{
uint8* MipData = Texture->Source.LockMip(0);
FMemory::Memcpy( MipData, RawPNG->GetData(), RawPNG->Num() );
// Replace the pixels with 0.0 alpha with a color value from the nearest neighboring color which has a non-zero alpha
FillZeroAlphaPNGData( Texture->Source, MipData );
}
else
{
Warn->Logf(ELogVerbosity::Error, TEXT("Failed to decode PNG.") );
Texture->Source.UnlockMip(0);
Texture->MarkPendingKill();
return nullptr;
}
Texture->Source.UnlockMip(0);
Texture->Source.LockMip(0); and Texture->Source.UnlockMip(0); were not paired in individual blocks.
Of cource, probability of executing failure code that is else block is very very low so it will not be a problem in most cases however should consider one in ten thousand case.
if ( PngImageWrapper->GetRaw( Format, BitDepth, RawPNG ) )
{
uint8* MipData = Texture->Source.LockMip(0);
FMemory::Memcpy( MipData, RawPNG->GetData(), RawPNG->Num() );
// Replace the pixels with 0.0 alpha with a color value from the nearest neighboring color which has a non-zero alpha
FillZeroAlphaPNGData( Texture->Source, MipData );
Texture->Source.UnlockMip(0);
}
else
{
Warn->Logf(ELogVerbosity::Error, TEXT("Failed to decode PNG.") );
Texture->MarkPendingKill();
return nullptr;
}
Above is much more correct I think. Additionally, the Texture was not locked before these blocks. so the Unlock in else block is needless.