allista / ConfigurableContainers

This is a plugin for KSP mod development.
MIT License
8 stars 7 forks source link

Attempting to change configuration when none exists results in NullReferenceException #16

Closed andrewcchen closed 6 years ago

andrewcchen commented 7 years ago

Clicking this button will cause the issue: 2017-08-12-151624_638x340_scrot

Stack trace from log:

NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.TextEditor.ClampTextIndex (System.Int32& index)
    UnityEngine.TextEditor.set_text (System.String value)
    UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style, System.String secureText, Char maskChar)
    UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style, System.String secureText)
    UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style)
    UnityEngine.GUILayout.DoTextField (System.String text, Int32 maxLength, Boolean multiline, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options)
    UnityEngine.GUILayout.TextField (System.String text, UnityEngine.GUILayoutOption[] options)
    AT_Utils.SwitchableTankManager.volume_configs_gui ()
    AT_Utils.SwitchableTankManager.TanksManagerGUI (Int32 windowId)
    UnityEngine.GUILayout+LayoutedWindow.DoWindow (Int32 windowID)
    UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style)
LouisCyfer commented 7 years ago

I experience that too .. maybe a check if available configs > 0 would be good (or if it is 0). I assume there's some fix needed there: https://github.com/allista/ConfigurableContainers/blob/a2eab81ee66d20e4dd09ee562453dfbe05b78e5e/SwitchableTankManagerGUI.cs#L189