diff --git a/EmoTracker.Data/AutoTracking/LuaMemorySegment.cs b/EmoTracker.Data/AutoTracking/LuaMemorySegment.cs index 0aa0254..28e77d0 100644 --- a/EmoTracker.Data/AutoTracking/LuaMemorySegment.cs +++ b/EmoTracker.Data/AutoTracking/LuaMemorySegment.cs @@ -58,8 +58,6 @@ public LuaMemorySegment() : base() protected override void OnSegmentDataUpdated() { - base.OnSegmentDataUpdated(); - var state = this.OwnerState as Sessions.TrackerState; if (state == null) return; var scripts = state.Scripts; @@ -76,10 +74,15 @@ protected override void OnSegmentDataUpdated() { try { + object[] result; using (new LocationDatabase.SuspendRefreshScope(state.Locations)) { - scripts.SafeCall(callback, this); + result = scripts.SafeCall(callback, this); } + bool succeeded = result != null && result.Length > 0 + && result[0] != null && !(result[0] is bool b && !b); + if (succeeded) + Dirty = false; } catch (Exception ex) { diff --git a/EmoTracker.Data/AutoTracking/MemorySegment.cs b/EmoTracker.Data/AutoTracking/MemorySegment.cs index b1a7b0c..5ac3bf7 100644 --- a/EmoTracker.Data/AutoTracking/MemorySegment.cs +++ b/EmoTracker.Data/AutoTracking/MemorySegment.cs @@ -33,7 +33,7 @@ namespace EmoTracker.Data.AutoTracking /// data (override ). /// /// - public class MemorySegment : ModelTypeBase, IMemorySegment, IUpdateWithConnector, IDisposable + public abstract class MemorySegment : ModelTypeBase, IMemorySegment, IUpdateWithConnector, IDisposable { #region -- Global Event Hooks -- @@ -339,9 +339,7 @@ public MemoryUpdateResult UpdateWithConnector(IAutoTrackingProvider provider, Pa /// overrides to dispatch onto the UI thread and SafeCall the /// pack-supplied LuaFunction callback. /// - protected virtual void OnSegmentDataUpdated() - { - } + protected abstract void OnSegmentDataUpdated(); public override void Dispose() { diff --git a/EmoTracker.Data/Debugging/LuaDebuggee.cs b/EmoTracker.Data/Debugging/LuaDebuggee.cs index db2eb6b..5557e53 100644 --- a/EmoTracker.Data/Debugging/LuaDebuggee.cs +++ b/EmoTracker.Data/Debugging/LuaDebuggee.cs @@ -667,6 +667,8 @@ void ServeRequest(DebugRequest req) internal void EnterExceptionPause(string errMessage, string traceback) { + if (!(LuaDebugServer.Instance?.HasActiveSession ?? false)) return; + // Always log so we can confirm the upcall actually // reached us — the Lua-side handler's pcall around the // upcall would otherwise silently swallow any throw.