post-kerbin-mining-corporation/DynamicBatteryStorage

NRE in DBS GUI if there are no powerConsumers

Closed this issue · 3 comments

Hi Chris,

one of those 2 lines is throwing NRE's if there are no consumers:

https://github.com/ChrisAdderley/DynamicBatteryStorage/blob/master/Source/DynamicBatteryStorage/DynamicBatteryStorageUI.cs#L158-L159

Errors from KSP.log:

NullReferenceException: Object reference not set to an instance of an object
at DynamicBatteryStorage.DynamicBatteryStorageUI.PowerWindow (Int32 windowId) [0x00000] in :0
at UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) [0x00000] in :0

(Filename: Line: -1)

GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)

(Filename: Line: 422)

Reproduce:

  • Launch a new vessel with only one part (any probecore will do)
  • open GUI (CTRL + SHIFT + k)
  • warp >= 100

I think this also happens if there are no producers.

I'll make sure this is resolved during refactoring

Resolved!