Giter Club home page Giter Club logo

Comments (5)

Lisias avatar Lisias commented on June 14, 2024

I had forgot about this one. Tackling it on 0.2.2.4, since I had to postpone the release for further testing Procedural Parts, as agreed on KSP-CKAN/NetKAN#9076 .

from ksp-recall.

Lisias avatar Lisias commented on June 14, 2024

This problem is COMPLETELY unrelated to KSP-Recall or TweakScale. On a KSP 1.12.3 without any of them, this exception also happened:

[LOG 20:05:21.374] PartLoader: Compiling Part 'REPOSoftTech/DeepFreeze/Parts/CRY0300Freezer/CRY-0300Freezer'
[LOG 20:05:21.401] DeepFreezer OnDestroy
[EXC 20:05:21.409] NullReferenceException: Object reference not set to an instance of an object
        DF.DeepFreezer.OnDestroy () (at <72233efaa3ee4936a15201f98fac7b68>:0)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        KSPe.Util.Log.UnityLogDecorator:UnityEngine.ILogHandler.LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.Object:DestroyImmediate(Object)
        PartLoader:StripComponent(GameObject)
        PartLoader:CreatePartIcon(GameObject, Single&)
        PartLoader:ParsePart(UrlConfig, ConfigNode)
        <CompileParts>d__56:MoveNext()
        UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Checking on the Deep Freeze [source code](https://github.com/JPLRepo/DeepFreeze/blob/9f509f75f1da3f79684b309da69c340c46bfa003/Source/DeepFreeze.cs#L214

):

        protected void OnDestroy()
        {
            Utilities.Log("OnDestroy");
            Instance = null;
            APIReady = false;
            foreach (Component child in children)
            {
                Utilities.Log("DeepFreeze Child Destroy for " + child.name);
                Destroy(child);
            }
            children.Clear();
            DeepFreezeEventRem();
            GameEvents.onGameSceneLoadRequested.Remove(OnGameSceneLoadRequested);
            GameEvents.OnGameSettingsApplied.Remove(ApplySettings);
        }

~I came to the conclusion that something changed on KSP 1.12 (as this code war working fine at least on KSP 1.9.1, in which I also teste it) that children is now null on while loading KSP (the point in which this exception happened). I think that checking for null will solve this issue.

In a way or another, it's a KSP 1.12.x induced problem on Deep Freeze, and it need to be tackled down by code on DF itself.~

EDIT: I WAS WRONG!

from ksp-recall.

Lisias avatar Lisias commented on June 14, 2024

Setting it as unrelated by obvious reasons, and closing this.

from ksp-recall.

Lisias avatar Lisias commented on June 14, 2024

KSP is not at fault here. This is what was really happening.

The DeepFreezePart.OnDestroy (the PartModule) was the code borking, not the DeepFreeze.OnDestroy (the Scenario Module).

That log message completely misguided me. The real problem is on this code:

https://github.com/JPLRepo/DeepFreeze/blob/9f509f75f1da3f79684b309da69c340c46bfa003/Source/DeepFreezerPart.cs#L1813

        private void OnDestroy()
        {
            //Remove GameEvent callbacks.
            Debug.Log("DeepFreezer OnDestroy");
            
                GameEvents.onCrewTransferPartListCreated.Remove(onCrewTransferPartListCreated);
                GameEvents.onCrewTransferred.Remove(onCrewTransferred);
                GameEvents.onVesselChange.Remove(OnVesselChange);
                GameEvents.onCrewBoardVessel.Remove(OnCrewBoardVessel);
                GameEvents.onCrewOnEva.Remove(onCrewOnEva);
                GameEvents.onVesselDestroy.Remove(onVesselDestroy);
                GameEvents.OnCameraChange.Remove(OnCameraChange);
                GameEvents.onVesselGoOffRails.Remove(onVesselGoOffRails);
                GameEvents.onVesselCrewWasModified.Remove(OnVesselCrewModified);
                DFGameEvents.onKerbalFrozen.Remove(OnKerbalFreezeThaw);     // <— HERE!!!
                DFGameEvents.onKerbalThaw.Remove(OnKerbalFreezeThaw);
                GameEvents.onVesselSwitching.Remove(OnVesselSwitching);
                if (onATPPodSettingChanged != null)
                {
                    onATPPodSettingChanged.Remove(OnATPPodSettingChanged);
                }
            
            Debug.Log("DeepFreezer END OnDestroy");
        }

The DGGameEvents structure os initialised only on the class Textures (whatahell??) on the Start method, here:

https://github.com/JPLRepo/DeepFreeze/blob/9f509f75f1da3f79684b309da69c340c46bfa003/Source/Textures.cs#L33

Problem. Besides Textures being completely unrelated to the DFGameEvents, the Texture MonoBehaviour is started only on the Main Menu : [KSPAddon(KSPAddon.Startup.MainMenu, false)]. So it's not a surprise that the DeepFreezePart's OnDestroy is borking, as the DFGameEvents are all still NULL at that point!

The easiest way out of this huge mess is to initialise DFGameEvents on the class loading, guaranteeing that the data structures will be immediately available for using.

The big question is not why DF started to throw exceptions now, but why it wasn't doing it before!

from ksp-recall.

Lisias avatar Lisias commented on June 14, 2024

A pull request was issued to the maintainer fixing the issue.

JPLRepo/DeepFreeze#110

from ksp-recall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.