Fixed crash which occurs when changing the material of an object twice in a row in the inspector #284

Merged
Pycorax merged 1 commits from Fix-Material into main 2022-11-25 22:34:31 +08:00
2 changed files with 4 additions and 1 deletions
Showing only changes of commit c84e33731b - Show all commits

View File

@ -66,10 +66,12 @@ namespace SHADE
{
oldMaterial = material;
material = {};
oldMatIsShared = false;
}
else if (sharedMaterial)
{
oldMaterial = sharedMaterial;
oldMatIsShared = true;
}
// Update the material
@ -150,7 +152,7 @@ namespace SHADE
{
matChanged = false;
meshChanged = false;
if (oldMaterial)
if (oldMaterial && !oldMatIsShared)
oldMaterial.Free();
oldMaterial = {};
oldMesh = {};

View File

@ -90,6 +90,7 @@ namespace SHADE
bool matChanged = true;
Handle<SHMaterialInstance> oldMaterial;
uint8_t lightLayer;
bool oldMatIsShared = false;
RTTR_ENABLE()
};