Skip to content

Commit

Permalink
Fixed memory leak caused by not removing callbacks from GameEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxgurugamer committed Sep 1, 2022
1 parent 94a9fac commit 07d07ce
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ChangeLog

1.1.6.4
Fixed memory leak caused by not removing callbacks from GameEvents

1.1.6.3
Renamed DLL for CKAN compatibility
Added AssemblyFileVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 1,
"MINOR": 1,
"PATCH": 6,
"BUILD": 3
"BUILD": 4
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion PartCommanderContinued.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 1,
"MINOR": 1,
"PATCH": 6,
"BUILD": 3
"BUILD": 4
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
9 changes: 2 additions & 7 deletions PartCommanderContinued/AssemblyVersion.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@






// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyVersion("1.1.6.3")]
[assembly: AssemblyFileVersion("1.1.6.3")]
[assembly: AssemblyVersion("1.1.6.4")]
[assembly: AssemblyFileVersion("1.1.6.4")]
14 changes: 9 additions & 5 deletions PartCommanderContinued/PartCommander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ public void OnGUI()
modStyle = modStyleKSP;
}
}

// Make sure we have something to show
if (visibleUI && FlightGlobals.ActiveVessel != null && currentWindow != null && PCScenario.Instance != null && PCScenario.Instance.gameSettings.visibleWindow)
{
GUI.skin = modStyle.skin;
GUI.skin = modStyle.skin;
currentWindow.windowRect = ClickThruBlocker.GUILayoutWindow(currentWindow.windowId, currentWindow.windowRect, mainWindow, "");
// Set the default location/size for new windows to be the same as this one
PCScenario.Instance.gameSettings.windowDefaultRect = currentWindow.windowRect;
Expand Down Expand Up @@ -377,6 +377,10 @@ protected void OnDestroy()

GameEvents.onGameSceneLoadRequested.Remove(onSceneChange);

GameEvents.onShowUI.Remove(showUI);
GameEvents.onHideUI.Remove(hideUI);
GameEvents.onVesselWasModified.Remove(triggerUpdateParts);
GameEvents.onVesselChange.Remove(triggerUpdateParts);
}

// ------------------------------------------ Application Launcher / UI ---------------------------------------
Expand Down Expand Up @@ -760,7 +764,7 @@ private void getActiveParts()
//foreach (PartModule pm in p.Modules)
{
PartModule pm = p.Modules[pmi];

if (includePart)
{
// Part was already included, so break out
Expand Down Expand Up @@ -1030,7 +1034,7 @@ private int showEvents(Part p, bool symLock, string multiEngineMode)
}
return eventCount;
}

static Color btnNrml = new Color(34f / 255f, 199f / 255f, 222f / 255f, 1);
static Texture2D BtnNrmlTex;

Expand Down Expand Up @@ -1077,7 +1081,7 @@ private void showEvent(Part p, bool symLock, PartModule pm, BaseEvent e, string

#endif
if (GUILayout.Button("", /* bStyle, */ GUILayout.Width(50), GUILayout.Height(15)))
{
{
if (symLock)
{
for (int i = 0; i < FlightGlobals.ActiveVessel.Parts.Count; i++)
Expand Down

0 comments on commit 07d07ce

Please sign in to comment.