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
This commit is contained in:
jean-pierre charras 2014-10-30 09:42:11 +01:00
parent 8814d67034
commit 09e20c6c0f
3 changed files with 35 additions and 71 deletions

View File

@ -40,7 +40,8 @@ class SCH_COMPONENT;
/* 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_SEGMENT, // connection by wire
NET_BUS, // connection by bus
@ -76,7 +77,8 @@ enum NETLIST_ITEM_T {
/* Values for .m_FlagOfConnection member */
enum NET_CONNECTION_T {
enum NET_CONNECTION_T
{
UNCONNECTED = 0, /* Pin or Label not connected (error) */
NOCONNECT_SYMBOL_PRESENT, /* Pin not connected but have a NoConnect
* symbol on it (no error) */
@ -87,33 +89,33 @@ enum NET_CONNECTION_T {
class NETLIST_OBJECT
{
public:
NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
EDA_ITEM* m_Comp; /* Pointer to the library item that
NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
EDA_ITEM* m_Comp; /* Pointer to the library item that
* 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
* contains this SCH_SHEET_PIN
* For Pins: pointer to the schematic component
* that contains this pin
*/
int m_Flag; /* flag used in calculations */
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
int m_Flag; /* flag used in calculations */
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
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 */
int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
* created from the BUS label ) member number.
*/
NET_CONNECTION_T m_ConnectionType; // Used to store the connection type
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
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_End; // For segments (wire and buses): ending point
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
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_End; // For segments (wire and buses): ending point
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
* as many net codes as bus members
*/
@ -123,10 +125,12 @@ private:
* When no label, the pin is used to build
* default net name.
*/
public:
#if defined(DEBUG)
void Show( std::ostream& out, int ndx ) const; // override
#endif
NETLIST_OBJECT();
@ -214,7 +218,7 @@ public:
*/
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:
};
/**
* 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
// 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_lastBusNetCode; // Used in intermediate calculation:
// last net code created for bus members
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
int m_lastNetCode; // Used in intermediate calculation: last net code created
int m_lastBusNetCode; // Used in intermediate calculation:
// last net code created for bus members
public:
/**
@ -293,7 +296,7 @@ public:
*/
NETLIST_OBJECT* GetItem( unsigned aIdx ) const
{
return *( this->begin() + aIdx );
return *( this->begin() + aIdx );
}
/*
@ -301,7 +304,7 @@ public:
*/
NETLIST_ITEM_T GetItemType( unsigned aIdx ) const
{
return GetItem( aIdx )->m_Type;
return GetItem( aIdx )->m_Type;
}
/*
@ -344,7 +347,7 @@ public:
/**
* Reset the connection type of all items to UNCONNECTED type
*/
void ResetConnectionsType( )
void ResetConnectionsType()
{
for( unsigned ii = 0; ii < size(); ii++ )
GetItem( ii )->SetConnectionType( UNCONNECTED );
@ -371,7 +374,9 @@ public:
GetItem( idx )->Show( std::cout, idx );
}
}
#endif
private:
/*
* Propagate aNewNetCode to items having an internal netcode aOldNetCode
@ -394,13 +399,13 @@ private:
return Objet1->GetNet() < Objet2->GetNet();
}
/* Comparison routine to sort items by Sheet Number
*/
static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
{
return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
}
/*
* Propagate net codes from a parent sheet to an include sheet,
* from a pin sheet connection
@ -452,4 +457,4 @@ private:
*/
extern bool IsBusLabel( const wxString& aLabel );
#endif // _CLASS_NETLIST_OBJECT_H_
#endif // _CLASS_NETLIST_OBJECT_H_

View File

@ -65,7 +65,6 @@ enum netlistOptions {
class SCH_COMPONENT;
class SCH_REFERENC_LIST;
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
@ -194,7 +193,7 @@ public:
/**
* 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
* the same component. This flattened list is used for netlist generation, BOM generation,
* and schematic annotation.
@ -483,46 +482,4 @@ private:
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_

View File

@ -73,6 +73,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
BOARD_CONNECTED_ITEM( aZone )
{
m_smoothedPoly = NULL;
// Should the copy be on the same net?
SetNetCode( aZone.GetNetCode() );
m_Poly = new CPolyLine( *aZone.m_Poly );