Assure that NETINFO_ITEMs have a NETCLASS object assigned

Fixes: lp:1705896
* https://bugs.launchpad.net/kicad/+bug/1705896
This commit is contained in:
Maciej Suminski 2017-07-28 16:03:15 +02:00
parent 2206d51b82
commit 75cda5021d
4 changed files with 21 additions and 24 deletions

View File

@ -86,7 +86,6 @@ NETCLASS::~NETCLASS()
NETCLASSES::NETCLASSES()
{
m_Default = std::make_shared<NETCLASS>( NETCLASS::Default );
}
@ -102,7 +101,7 @@ bool NETCLASSES::Add( NETCLASSPTR aNetClass )
if( name == NETCLASS::Default )
{
// invoke operator=(), which is currently generated by compiler.
m_Default = aNetClass;
GetDefault() = aNetClass;
return true;
}
@ -142,7 +141,7 @@ NETCLASSPTR NETCLASSES::Remove( const wxString& aNetName )
NETCLASSPTR NETCLASSES::Find( const wxString& aName ) const
{
if( aName == NETCLASS::Default )
return m_Default;
return GetDefault();
NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );

View File

@ -235,9 +235,6 @@ private:
/// all the NETCLASSes except the default one.
NETCLASS_MAP m_NetClasses;
/// the default NETCLASS.
NETCLASSPTR m_Default;
public:
NETCLASSES();
~NETCLASSES();
@ -272,9 +269,10 @@ public:
* Function GetDefault
* @return the default net class.
*/
NETCLASSPTR GetDefault() const
NETCLASSPTR& GetDefault() const
{
return m_Default;
static NETCLASSPTR defNetClass = std::make_shared<NETCLASS>( NETCLASS::Default );
return defNetClass;
}
/**

View File

@ -78,9 +78,6 @@ private:
wxString m_ShortNetname; ///< short net name, like vout from /mysheet/mysubsheet/vout
wxString m_NetClassName; // Net Class name. if void this is equivalent
// to "default" (the first
// item of the net classes list
NETCLASSPTR m_NetClass;
BOARD* m_parent; ///< The parent board the net belongs to.
@ -120,15 +117,7 @@ public:
* Function SetClass
* sets \a aNetclass into this NET
*/
void SetClass( NETCLASSPTR aNetClass )
{
m_NetClass = aNetClass;
if( aNetClass )
m_NetClassName = aNetClass->GetName();
else
m_NetClassName = NETCLASS::Default;
}
void SetClass( NETCLASSPTR aNetClass );
NETCLASSPTR GetNetClass()
{
@ -139,9 +128,9 @@ public:
* Function GetClassName
* returns the class name
*/
const wxString& GetClassName() const
wxString GetClassName() const
{
return m_NetClassName;
return m_NetClass ? m_NetClass->GetName() : NETCLASS::Default;
}
#if 1

View File

@ -54,7 +54,11 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCo
m_NetCode( aNetCode ), m_Netname( aNetName ), m_ShortNetname( m_Netname.AfterLast( '/' ) )
{
m_parent = aParent;
m_NetClassName = NETCLASS::Default;
if( aParent )
m_NetClass = aParent->GetDesignSettings().m_NetClasses.GetDefault();
else
m_NetClass = std::make_shared<NETCLASS>( "<invalid>" );
}
@ -75,6 +79,13 @@ void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel,
}
void NETINFO_ITEM::SetClass( NETCLASSPTR aNetClass )
{
wxCHECK( m_parent, /* void */ );
m_NetClass = aNetClass ? aNetClass : m_parent->GetDesignSettings().m_NetClasses.GetDefault();
}
void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{
wxString txt;