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) */
...@@ -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();
...@@ -251,12 +255,11 @@ public: ...@@ -251,12 +255,11 @@ 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
...@@ -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
......
...@@ -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