SSTU - Shadow Space Technologies Unlimited

SSTU - Shadow Space Technologies Unlimited

98.5k Downloads

Crash when updating flag visibility on symmetric part

blowfishpro opened this issue ยท 3 comments

commented

This one looks like it's going to be a pain to debug (if even debuggable), so I apologize in advance for that. If we're lucky it's a configuration issue on my end.

Here's what I did

  • Place some part as the root part in the VAB
  • Attach two modular tanks in symmetry mode to the root part
  • Click "toggle flag visibility" on one of the tanks
  • KSP crashes, no info in the log

Will try to get more info as I have time

commented

As long as I have steps to reproduce, I can find some way to debug it, even if its just memory dumps and object graphs.

Will investigate this one this evening; it could be a simple infinite loop in the symmetry update code -- stack-overflows usually don't cause crash-logs unless they are an extremely tight/short loop (this loop likely chokes on object allocation so never triggers the overflow checks/never reaches the point of overflow), and even then the logs are rarely useful.

commented

LoL, yep; stack-overflow through infinite recursion:

[KSPEvent(guiName = "Toggle Flag Visibility", guiActiveEditor = true)]
        public void toggleFlagEvent()
        {
            flagEnabled = !flagEnabled;
            updateFlagTransform();
            int index = part.Modules.IndexOf(this);
            foreach (Part p in part.symmetryCounterparts) { ((SSTUFlagDecal)p.Modules[index]).toggleFlagEvent(); }
        }

Will have a fix in place shortly, will be available with the next update (after I actually test it this time...)

commented

Looks much less crash-inducing now:

        [KSPEvent(guiName = "Toggle Flag Visibility", guiActiveEditor = true)]
        public void toggleFlagEvent()
        {
            onFlagToggled(true);
        }

        private void onFlagToggled(bool updateSymmetry)
        {
            flagEnabled = !flagEnabled;
            updateFlagTransform();
            if (updateSymmetry)
            {
                int index = part.Modules.IndexOf(this);
                foreach (Part p in part.symmetryCounterparts) { ((SSTUFlagDecal)p.Modules[index]).onFlagToggled(false); }
            }
        }