Flight engineer menu sections are now dynamically removed from the list upon deletion.
Flight engineer menu sections are now dynamically removed from the list upon deletion.

--- a/KerbalEngineer.Unity/Flight/FlightMenuSection.cs
+++ b/KerbalEngineer.Unity/Flight/FlightMenuSection.cs
@@ -102,8 +102,9 @@
         /// </summary>
         private void UpdateControls()
         {
-            if (m_Section == null)
+            if (m_Section == null || m_Section.IsDeleted)
             {
+                Destroy(gameObject);
                 return;
             }
 

--- a/KerbalEngineer.Unity/Flight/ISectionModule.cs
+++ b/KerbalEngineer.Unity/Flight/ISectionModule.cs
@@ -20,6 +20,8 @@
 {
     public interface ISectionModule
     {
+        bool IsDeleted { get; }
+
         bool IsEditorVisible { get; set; }
 
         bool IsVisible { get; set; }

--- a/KerbalEngineer/Flight/Sections/SectionEditor.cs
+++ b/KerbalEngineer/Flight/Sections/SectionEditor.cs
@@ -236,6 +236,7 @@
                 {
                     this.ParentSection.IsFloating = false;
                     this.ParentSection.IsEditorVisible = false;
+                    this.ParentSection.IsDeleted = true;
                     SectionLibrary.CustomSections.Remove(this.ParentSection);
                     DisplayStack.Instance.RequestResize();
                 }

--- a/KerbalEngineer/Flight/Sections/SectionModule.cs
+++ b/KerbalEngineer/Flight/Sections/SectionModule.cs
@@ -159,6 +159,11 @@
         }
 
         /// <summary>
+        ///     Gets and sets whether the section module has been deleted.
+        /// </summary>
+        public bool IsDeleted { get; set; }
+
+        /// <summary>
         ///     Gets and sets whether the section module has a background as a HUD.
         /// </summary>
         public bool IsHudBackground { get; set; }