diff --git a/CHANGELOG.md b/CHANGELOG.md index de608e4..7a07421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file | website | https://forum.kerbalspaceprogram.com/index.php?/topic/194802-18-111-conformal-decals | | author | Andrew Cassidy | + +## 0.2.11 - Unreleased, changes submitted by Linuxgurugamer + Fixed nullref caused when an entry in _targets was null + Fixed memory leak caused by the OnDestroy() methods not being called due to them being virtual + + ## 0.2.10 - 2022-03-14 ### Fixed @@ -190,4 +196,4 @@ Initial release! - CDL-F Flag Decal: Conformal flag decal, which uses either the mission flag or a flag of your choosing. - CDL-1 Generic Decal: A set of conformal generic decals for planes and rockets -- CDL-2 Semiotic Standard Decal: A set of conformal decals based on the Semiotic Standard for All Commercial Trans-Stellar Utility Lifter and Transport Spacecraft designed by Ron Cobb for the movie Alien \ No newline at end of file +- CDL-2 Semiotic Standard Decal: A set of conformal decals based on the Semiotic Standard for All Commercial Trans-Stellar Utility Lifter and Transport Spacecraft designed by Ron Cobb for the movie Alien diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs index 279bc28..d1c77ea 100644 --- a/Source/ConformalDecals/ModuleConformalDecal.cs +++ b/Source/ConformalDecals/ModuleConformalDecal.cs @@ -283,7 +283,7 @@ namespace ConformalDecals { } } - public virtual void OnDestroy() { + public void OnDestroy() { // remove GameEvents if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorPartEvent.Remove(OnEditorEvent); @@ -440,7 +440,8 @@ namespace ConformalDecals { // update projection foreach (var target in _targets) { - target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal); + if (target != null) + target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal); } } else { @@ -577,7 +578,8 @@ namespace ConformalDecals { // render on each target object foreach (var target in _targets) { - target.Render(_decalMaterial, part.mpb, camera); + if (target != null) + target.Render(_decalMaterial, part.mpb, camera); } } } diff --git a/Source/ConformalDecals/ModuleConformalFlag.cs b/Source/ConformalDecals/ModuleConformalFlag.cs index ca249f3..73df416 100644 --- a/Source/ConformalDecals/ModuleConformalFlag.cs +++ b/Source/ConformalDecals/ModuleConformalFlag.cs @@ -48,14 +48,12 @@ namespace ConformalDecals { UpdateFlag(); } - public override void OnDestroy() { + public void OnDestroy() { if (HighLogic.LoadedSceneIsEditor) { // Unregister flag change event GameEvents.onMissionFlagSelect.Remove(OnEditorFlagSelected); } - - base.OnDestroy(); - } + } [KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")] public void SelectFlag() { diff --git a/Source/ConformalDecals/ModuleConformalText.cs b/Source/ConformalDecals/ModuleConformalText.cs index b3948d8..c1388ef 100644 --- a/Source/ConformalDecals/ModuleConformalText.cs +++ b/Source/ConformalDecals/ModuleConformalText.cs @@ -220,15 +220,13 @@ namespace ConformalDecals { } } - public override void OnDestroy() { + public void OnDestroy() { if (HighLogic.LoadedSceneIsGame && _currentText != null) TextRenderer.UnregisterText(_currentText); // close all UIs if (_textEntryController != null) _textEntryController.Close(); if (_fillColorPickerController != null) _fillColorPickerController.Close(); if (_outlineColorPickerController != null) _outlineColorPickerController.Close(); - - base.OnDestroy(); } protected override void OnDetach() {