Jump to content

Nullref at RUI.Algorithms.SCCFlowGraphUCFinder.IsEntryPointRequest


Recommended Posts

I'm getting a strange nullref, and haven't yet figured it out.

Background:  I have a new module which inherits from ModuleEngines.  During the OnAwake() call, it checks some parts, and if something is missing,  it then does a Destroy(this).  

Code:

Spoiler

void OnAwake()
{
	if (PartLoader.DoesPartExist(TechName))
	{
		techPart = PartLoader.getPartInfoByName(TechName);
		techPartResearched = PartResearched(techPart);
		if (!techPartResearched)
		{
			// remove the fuel since it isn't being used
			// disabling this section did not affect the error 
			if (this.part != null)
			{
				PartResourceList prl = this.part.Resources;
				if (prl.Contains(ModSegSRBs.SeparatronFuel))
					prl.Remove(ModSegSRBs.SeparatronFuel);
			}
			if (HighLogic.LoadedScene != GameScenes.LOADING)
			{
				Destroy(this);
			}
		}
	}
}

 

 

Nullref error:

Spoiler


NullReferenceException: Object reference not set to an instance of an object
  at RUI.Algorithms.SCCFlowGraphUCFinder.IsEntryPointRequest (.Part part, .Callback`1 requestCallback) [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder.IsEntryPoint (.Part part, .Callback`1 deliveryCallback, .Callback`1 requestCallback) [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder.BuildEntrySets () [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder..ctor (System.Collections.Generic.List`1 ship) [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EngineersReport+<RunTests>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in <filename unknown>:0 

 

 

This error occurs when the part in question is added to the vessel.  This affects two things.  First and most important, the right-click PAW on all parts is broken.  Second, the Engineer's Report is also broken.

This has me stumped, any help would be appreciated.

Link to comment
Share on other sites

  • 3 weeks later...
On 9/22/2019 at 10:38 AM, linuxgurugamer said:

I'm getting a strange nullref, and haven't yet figured it out.

Background:  I have a new module which inherits from ModuleEngines.  During the OnAwake() call, it checks some parts, and if something is missing,  it then does a Destroy(this).  

Code:

  Hide contents


void OnAwake()
{
	if (PartLoader.DoesPartExist(TechName))
	{
		techPart = PartLoader.getPartInfoByName(TechName);
		techPartResearched = PartResearched(techPart);
		if (!techPartResearched)
		{
			// remove the fuel since it isn't being used
			// disabling this section did not affect the error 
			if (this.part != null)
			{
				PartResourceList prl = this.part.Resources;
				if (prl.Contains(ModSegSRBs.SeparatronFuel))
					prl.Remove(ModSegSRBs.SeparatronFuel);
			}
			if (HighLogic.LoadedScene != GameScenes.LOADING)
			{
				Destroy(this);
			}
		}
	}
}

 

 

Nullref error:

  Hide contents



NullReferenceException: Object reference not set to an instance of an object
  at RUI.Algorithms.SCCFlowGraphUCFinder.IsEntryPointRequest (.Part part, .Callback`1 requestCallback) [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder.IsEntryPoint (.Part part, .Callback`1 deliveryCallback, .Callback`1 requestCallback) [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder.BuildEntrySets () [0x00000] in <filename unknown>:0 
  at RUI.Algorithms.SCCFlowGraphUCFinder..ctor (System.Collections.Generic.List`1 ship) [0x00000] in <filename unknown>:0 
  at KSP.UI.Screens.EngineersReport+<RunTests>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in <filename unknown>:0 

 

 

This error occurs when the part in question is added to the vessel.  This affects two things.  First and most important, the right-click PAW on all parts is broken.  Second, the Engineer's Report is also broken.

This has me stumped, any help would be appreciated.

Instead of

if (prl.Contains(ModSegSRBs.SeparatronFuel))
					prl.Remove(ModSegSRBs.SeparatronFuel);

You should be using part.RemoveResource()

 

However, I don't think that's the problem rather it's:

if (HighLogic.LoadedScene != GameScenes.LOADING)
			{
				Destroy(this);
			}

you destroy the module. Without telling the part and removing it from the part.Modules list. Hence the NRE.

You should be using part.RemoveModule(PartModule module) as this will remove it correctly from the Modules list and destroy the module for you.

Link to comment
Share on other sites

1 hour ago, JPLRepo said:

Instead of


if (prl.Contains(ModSegSRBs.SeparatronFuel))
					prl.Remove(ModSegSRBs.SeparatronFuel);

You should be using part.RemoveResource()

 

However, I don't think that's the problem rather it's:


if (HighLogic.LoadedScene != GameScenes.LOADING)
			{
				Destroy(this);
			}

you destroy the module. Without telling the part and removing it from the part.Modules list. Hence the NRE.

You should be using part.RemoveModule(PartModule module) as this will remove it correctly from the Modules list and destroy the module for you.

I had actually worked around the problem, thank you for pointing out a better way.

Re. the resource, I had been setting it to 0, removing it is a better answer, but I'll have to make sure that doesn't cause any other issues.

Thank you

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...