Commit 09e20c6c authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix a serious bug in ZONE_CONTAINER class copy constructor: a pointer...

Pcbnew: fix a serious bug in ZONE_CONTAINER class copy constructor: a pointer was not initialized. Pcbnew crashes when deleting or filling a copied zone.
Eeschema: remove dead code and uncrutify class_netlist_object.h
parent 8814d670
...@@ -40,7 +40,8 @@ class SCH_COMPONENT; ...@@ -40,7 +40,8 @@ class SCH_COMPONENT;
/* Type of Net objects (wires, labels, pins...) */ /* Type of Net objects (wires, labels, pins...) */
enum NETLIST_ITEM_T { enum NETLIST_ITEM_T
{
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
NET_SEGMENT, // connection by wire NET_SEGMENT, // connection by wire
NET_BUS, // connection by bus NET_BUS, // connection by bus
...@@ -76,7 +77,8 @@ enum NETLIST_ITEM_T { ...@@ -76,7 +77,8 @@ enum NETLIST_ITEM_T {
/* Values for .m_FlagOfConnection member */ /* Values for .m_FlagOfConnection member */
enum NET_CONNECTION_T { enum NET_CONNECTION_T
{
UNCONNECTED = 0, /* Pin or Label not connected (error) */ UNCONNECTED = 0, /* Pin or Label not connected (error) */
NOCONNECT_SYMBOL_PRESENT, /* Pin not connected but have a NoConnect NOCONNECT_SYMBOL_PRESENT, /* Pin not connected but have a NoConnect
* symbol on it (no error) */ * symbol on it (no error) */
...@@ -87,33 +89,33 @@ enum NET_CONNECTION_T { ...@@ -87,33 +89,33 @@ enum NET_CONNECTION_T {
class NETLIST_OBJECT class NETLIST_OBJECT
{ {
public: public:
NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */ NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
EDA_ITEM* m_Comp; /* Pointer to the library item that EDA_ITEM* m_Comp; /* Pointer to the library item that
* created this net object (the parent) * created this net object (the parent)
*/ */
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN: SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
* Pointer to the hierarchy sheet that * Pointer to the hierarchy sheet that
* contains this SCH_SHEET_PIN * contains this SCH_SHEET_PIN
* For Pins: pointer to the schematic component * For Pins: pointer to the schematic component
* that contains this pin * that contains this pin
*/ */
int m_Flag; /* flag used in calculations */ int m_Flag; /* flag used in calculations */
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label
int m_ElectricalType; /* Has meaning only for Pins and int m_ElectricalType; /* Has meaning only for Pins and
* hierarchical pins: electrical type */ * hierarchical pins: electrical type */
int m_BusNetCode; /* Used for BUS connections */ int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
* created from the BUS label ) member number. * created from the BUS label ) member number.
*/ */
NET_CONNECTION_T m_ConnectionType; // Used to store the connection type NET_CONNECTION_T m_ConnectionType; // Used to store the connection type
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes) long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
wxString m_Label; // Label text (for labels) or Pin name (for pins) wxString m_Label; // Label text (for labels) or Pin name (for pins)
wxPoint m_Start; // Position of object or for segments: starting point wxPoint m_Start; // Position of object or for segments: starting point
wxPoint m_End; // For segments (wire and buses): ending point wxPoint m_End; // For segments (wire and buses): ending point
private: private:
int m_netCode; /* net code for all items except BUS int m_netCode; /* net code for all items except BUS
* labels because a BUS label has * labels because a BUS label has
* as many net codes as bus members * as many net codes as bus members
*/ */
...@@ -123,10 +125,12 @@ private: ...@@ -123,10 +125,12 @@ private:
* When no label, the pin is used to build * When no label, the pin is used to build
* default net name. * default net name.
*/ */
public: public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( std::ostream& out, int ndx ) const; // override void Show( std::ostream& out, int ndx ) const; // override
#endif #endif
NETLIST_OBJECT(); NETLIST_OBJECT();
...@@ -214,7 +218,7 @@ public: ...@@ -214,7 +218,7 @@ public:
*/ */
bool IsLabelGlobal() const bool IsLabelGlobal() const
{ {
return ( m_Type == NET_PINLABEL ) || ( m_Type == NET_GLOBLABEL ); return ( m_Type == NET_PINLABEL ) || ( m_Type == NET_GLOBLABEL );
} }
/** /**
...@@ -251,18 +255,17 @@ public: ...@@ -251,18 +255,17 @@ public:
}; };
/** /**
* NETLIST_OBJECT_LIST is a class to handle the list of connected items * NETLIST_OBJECT_LIST is a class to handle the list of connected items
* in a full shematic hierarchy for netlist and erc calculations * in a full schematic hierarchy for netlist and erc calculations
*/ */
class NETLIST_OBJECT_LIST: public std::vector <NETLIST_OBJECT*> class NETLIST_OBJECT_LIST : public std::vector <NETLIST_OBJECT*>
{ {
bool m_isOwner; // = true if the objects in list are owned my me, and therefore bool m_isOwner; // = true if the objects in list are owned my me, and therefore
// the memory should be freed by the destructor and the list cleared // the memory should be freed by the destructor and the list cleared
int m_lastNetCode; // Used in intermediate calculation: last net code created int m_lastNetCode; // Used in intermediate calculation: last net code created
int m_lastBusNetCode; // Used in intermediate calculation: int m_lastBusNetCode; // Used in intermediate calculation:
// last net code created for bus members // last net code created for bus members
public: public:
/** /**
...@@ -293,7 +296,7 @@ public: ...@@ -293,7 +296,7 @@ public:
*/ */
NETLIST_OBJECT* GetItem( unsigned aIdx ) const NETLIST_OBJECT* GetItem( unsigned aIdx ) const
{ {
return *( this->begin() + aIdx ); return *( this->begin() + aIdx );
} }
/* /*
...@@ -301,7 +304,7 @@ public: ...@@ -301,7 +304,7 @@ public:
*/ */
NETLIST_ITEM_T GetItemType( unsigned aIdx ) const NETLIST_ITEM_T GetItemType( unsigned aIdx ) const
{ {
return GetItem( aIdx )->m_Type; return GetItem( aIdx )->m_Type;
} }
/* /*
...@@ -344,7 +347,7 @@ public: ...@@ -344,7 +347,7 @@ public:
/** /**
* Reset the connection type of all items to UNCONNECTED type * Reset the connection type of all items to UNCONNECTED type
*/ */
void ResetConnectionsType( ) void ResetConnectionsType()
{ {
for( unsigned ii = 0; ii < size(); ii++ ) for( unsigned ii = 0; ii < size(); ii++ )
GetItem( ii )->SetConnectionType( UNCONNECTED ); GetItem( ii )->SetConnectionType( UNCONNECTED );
...@@ -371,7 +374,9 @@ public: ...@@ -371,7 +374,9 @@ public:
GetItem( idx )->Show( std::cout, idx ); GetItem( idx )->Show( std::cout, idx );
} }
} }
#endif #endif
private: private:
/* /*
* Propagate aNewNetCode to items having an internal netcode aOldNetCode * Propagate aNewNetCode to items having an internal netcode aOldNetCode
...@@ -394,13 +399,13 @@ private: ...@@ -394,13 +399,13 @@ private:
return Objet1->GetNet() < Objet2->GetNet(); return Objet1->GetNet() < Objet2->GetNet();
} }
/* Comparison routine to sort items by Sheet Number /* Comparison routine to sort items by Sheet Number
*/ */
static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 ) static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
{ {
return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0; return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
} }
/* /*
* Propagate net codes from a parent sheet to an include sheet, * Propagate net codes from a parent sheet to an include sheet,
* from a pin sheet connection * from a pin sheet connection
...@@ -452,4 +457,4 @@ private: ...@@ -452,4 +457,4 @@ private:
*/ */
extern bool IsBusLabel( const wxString& aLabel ); extern bool IsBusLabel( const wxString& aLabel );
#endif // _CLASS_NETLIST_OBJECT_H_ #endif // _CLASS_NETLIST_OBJECT_H_
...@@ -65,7 +65,6 @@ enum netlistOptions { ...@@ -65,7 +65,6 @@ enum netlistOptions {
class SCH_COMPONENT; class SCH_COMPONENT;
class SCH_REFERENC_LIST;
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
...@@ -194,7 +193,7 @@ public: ...@@ -194,7 +193,7 @@ public:
/** /**
* Class SCH_REFERENCE_LIST * Class SCH_REFERENCE_LIST
* is used create a flattened list of components because in a complex hierarchy, a component * is used to create a flattened list of components because in a complex hierarchy, a component
* can be used more than once and its reference designator is dependent on the sheet path for * can be used more than once and its reference designator is dependent on the sheet path for
* the same component. This flattened list is used for netlist generation, BOM generation, * the same component. This flattened list is used for netlist generation, BOM generation,
* and schematic annotation. * and schematic annotation.
...@@ -483,46 +482,4 @@ private: ...@@ -483,46 +482,4 @@ private:
int CreateFirstFreeRefId( std::vector<int>& aIdList, int aFirstValue ); int CreateFirstFreeRefId( std::vector<int>& aIdList, int aFirstValue );
}; };
/**
* Class BOM_LABEL
* is used to build a List of Labels by handling the list of labels in schematic because in a
* complex hierarchy, a label is used more than once and has more than one sheet path
* so we must create a flat list of labels.
*/
class BOM_LABEL
{
KICAD_T m_type;
SCH_ITEM* m_label;
// have to store it here since the object references will be duplicated.
SCH_SHEET_PATH m_sheetPath; //composed of UIDs
static const SCH_SHEET_PATH emptySheetPath;
public:
BOM_LABEL( KICAD_T aType = TYPE_NOT_INIT, SCH_ITEM* aLabel = NULL,
const SCH_SHEET_PATH& aSheetPath = emptySheetPath )
: m_type( aType )
, m_label( aLabel )
, m_sheetPath( aSheetPath )
{
}
KICAD_T GetType() const { return m_type; }
const SCH_ITEM* GetLabel() const { return m_label; }
const SCH_SHEET_PATH& GetSheetPath() const { return m_sheetPath; }
wxString GetText() const
{
const SCH_TEXT* tmp = static_cast<SCH_TEXT*>( m_label );
return tmp->GetText();
}
};
typedef std::vector <BOM_LABEL> BOM_LABEL_LIST;
#endif // _NETLIST_H_ #endif // _NETLIST_H_
...@@ -73,6 +73,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) : ...@@ -73,6 +73,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) : ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
BOARD_CONNECTED_ITEM( aZone ) BOARD_CONNECTED_ITEM( aZone )
{ {
m_smoothedPoly = NULL;
// Should the copy be on the same net? // Should the copy be on the same net?
SetNetCode( aZone.GetNetCode() ); SetNetCode( aZone.GetNetCode() );
m_Poly = new CPolyLine( *aZone.m_Poly ); m_Poly = new CPolyLine( *aZone.m_Poly );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment