// Disposer public override void Dispose() { // Not already disposed? if (!isdisposed) { // Already set isdisposed so that changes can be prohibited isdisposed = true; // Dispose the sidedefs that are attached to this sector // because a sidedef cannot exist without reference to its sector. if (map.AutoRemove) { foreach (Sidedef sd in sidedefs) { sd.Dispose(); } } else { foreach (Sidedef sd in sidedefs) { sd.SetSectorP(null); } } if (map == General.Map.Map) { General.Map.UndoRedo.RecRemSector(this); } // Remove from main list map.RemoveSector(listindex); // Register the index as free map.AddSectorIndexHole(fixedindex); // Free surface entry General.Map.CRenderer2D.Surfaces.FreeSurfaces(surfaceentries); // Clean up sidedefs = null; map = null; //mxd. Restore isdisposed so base classes can do their disposal job isdisposed = false; // Dispose base base.Dispose(); } }