RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Core Gumps: Stack Overflow / Possible Null Reference

Vorspire

Knight
I've stumbled upon a couple of issues while developing my SuperGumps framework, an instance where I call Gump.Remove( GumpEntry) - I'm assuming it hasn't been found yet and only because it's never actually been used by anything yet, however I decided to report it in case anyone is having problems tracing it.


Gump.CS (Line 330~)

StackOverflowException:
Code:
public void Remove( GumpEntry g )
{
	Invalidate();
	m_Entries.Remove(g);
	g.Parent = null; //set accessor calls Gump.Remove( g )
}

Fix:
Code:
public void Remove( GumpEntry g )
{
	if (g == null || !m_Entries.Contains(g))
	{
		return;
	}

	Invalidate();
	m_Entries.Remove(g);
	g.Parent = null;
}


GumpEntry.cs (Line 90~)
NullReferenceException:
Code:
if ( m_Parent != value )
{
	if ( m_Parent != null )
	{
		m_Parent.Remove( this );
	}

	m_Parent = value;

	m_Parent.Add( this ); //m_Parent may be null
}

Fix:
Code:
if (m_Parent == value)
{
	return;
}

if (m_Parent != null)
{
	m_Parent.Remove(this);
}

m_Parent = value;

if (m_Parent != null)
{
	m_Parent.Add(this);
}
 
Top