Fix exception state being "sticky"

This commit is contained in:
Sinai 2022-04-11 17:37:03 +10:00
parent 4af86e0e25
commit 62fa7f30f3
2 changed files with 35 additions and 19 deletions

View File

@ -96,23 +96,6 @@ namespace UnityExplorer.CacheObject
// Updating and applying values
public void SetUserValue(object value)
{
value = value.TryCast(FallbackType);
TrySetUserValue(value);
if (CellView != null)
SetDataToCell(CellView);
// If the owner's ParentCacheObject is set, we are setting the value of an inspected struct.
// Set the inspector target as the value back to that parent.
if (Owner.ParentCacheObject != null)
Owner.ParentCacheObject.SetUserValue(Owner.Target);
}
public abstract void TrySetUserValue(object value);
// The only method which sets the CacheObjectBase.Value
public virtual void SetValueFromSource(object value)
{
@ -132,6 +115,23 @@ namespace UnityExplorer.CacheObject
}
}
public void SetUserValue(object value)
{
value = value.TryCast(FallbackType);
TrySetUserValue(value);
if (CellView != null)
SetDataToCell(CellView);
// If the owner's ParentCacheObject is set, we are setting the value of an inspected struct.
// Set the inspector target as the value back to that parent.
if (Owner.ParentCacheObject != null)
Owner.ParentCacheObject.SetUserValue(Owner.Target);
}
public abstract void TrySetUserValue(object value);
protected virtual void ProcessOnEvaluate()
{
var prevState = State;
@ -171,7 +171,7 @@ namespace UnityExplorer.CacheObject
public ValueState GetStateForType(Type type)
{
if (LastValueType == type)
if (LastValueType == type && (State != ValueState.Exception || LastException != null))
return State;
LastValueType = type;

View File

@ -28,7 +28,23 @@ namespace UnityExplorer.Tests
public static object LiterallyAnything = null;
public static string Exception => throw new Exception("This is a test.");
public static string Exception
{
get
{
if (!shouldThrow)
{
shouldThrow = true;
throw new Exception("This is a test.");
}
else
{
shouldThrow = false;
return "No exception";
}
}
}
static bool shouldThrow;
// Test enumerables
public static int[,,] MultiDimensionalArray = new int[45, 45, 45];