KerbalAlarmClock icon indicating copy to clipboard operation
KerbalAlarmClock copied to clipboard

Calling DeleteAlarm while that alarm's window is open creates a harmless NRE

Open Clayell opened this issue 5 months ago • 1 comments

Ran into this issue while testing https://github.com/KSP-RO/RP-1/pull/2618 and calling DeleteAlarm. This log is generated:

(for this specific usecase, the alarm is deleted very quickly after being triggered)

9/24/2025 6:01:46 PM, KerbalAlarm Clock, Triggering Alarm - RP-1: Satellite Era Science Complete
9/24/2025 6:01:46 PM, KerbalAlarm Clock, RP-1: Satellite Era Science Complete-Halt Warp
9/24/2025 6:01:46 PM, KerbalAlarm Clock, Actioning Alarm
9/24/2025 6:01:46 PM, KerbalAlarm Clock, API-DeleteAlarm-
Deleting:08a4bc047342422497c27f413a6bbfc6
[EXC 18:01:46.539] NullReferenceException: Object reference not set to an instance of an object
    KerbalAlarmClock.KerbalAlarmClock.FillAlarmWindow (System.Int32 windowID) (at <d69ce5a979e54db99b605106fabdee09>:0)
    UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at <58f888e0d56a4620958c8e58a768c70d>:0)
    UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at <58f888e0d56a4620958c8e58a768c70d>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Calling the stock AlarmClockScenario.DeleteAlarm method while a stock alarm window is open doesn't cause any issues, KSP just seems to handle it, so this is a (slight) regression from stock. The NRE doesn't seem to cause anything to break, the alarm window closes fine afterwards.

Clayell avatar Sep 25 '25 19:09 Clayell

Likely reason for this: https://github.com/KSP-RO/RP-1/pull/2618#issuecomment-3333913167

siimav avatar Sep 28 '25 12:09 siimav