Commit f31f92e4 authored by Maciej Suminski's avatar Maciej Suminski

Fixes the bug that causes pcbnew crash, when there are multiple net classes...

Fixes the bug that causes pcbnew crash, when there are multiple net classes and the plot dialog was opened.
Changed NETCLASS* to boost::shared_ptr<NETCLASS>.
parent f49e9a28
......@@ -105,7 +105,7 @@ public:
* Function GetDefault
* @return the default netclass.
*/
inline NETCLASS* GetDefault() const
inline NETCLASSPTR GetDefault() const
{
return m_NetClasses.GetDefault();
}
......
......@@ -201,7 +201,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
LAYER_MSK layerMask;
// use the default NETCLASS?
NETCLASS* nc = aPcb->GetDesignSettings().GetDefault();
NETCLASSPTR nc = aPcb->GetDesignSettings().GetDefault();
int trackWidth = nc->GetTrackWidth();
int clearance = nc->GetClearance();
......
......@@ -91,7 +91,7 @@ BOARD::BOARD() :
m_Layer[layer].m_Type = LT_UNDEFINED;
}
NETCLASS* defaultClass = m_designSettings.GetDefault();
NETCLASSPTR defaultClass = m_designSettings.GetDefault();
defaultClass->SetDescription( _( "This is the default net class." ) );
// Initialize default values in default netclass.
......
......@@ -89,7 +89,7 @@ const wxString& BOARD_CONNECTED_ITEM::GetShortNetname() const
int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
NETCLASS* myclass = GetNetClass();
NETCLASSPTR myclass = GetNetClass();
// DO NOT use wxASSERT, because GetClearance is called inside an OnPaint event
// and a call to wxASSERT can crash the application.
......@@ -116,7 +116,7 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
}
NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
NETCLASSPTR BOARD_CONNECTED_ITEM::GetNetClass() const
{
// It is important that this be implemented without any sequential searching.
// Simple array lookups should be fine, performance-wise.
......@@ -128,10 +128,11 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
if( board == NULL ) // Should not occur
{
DBG(printf( "%s: NULL board,type %d", __func__, Type() );)
return NULL;
return NETCLASSPTR();
}
NETCLASS* netclass = NULL;
NETCLASSPTR netclass;
NETINFO_ITEM* net = board->FindNet( GetNetCode() );
if( net )
......@@ -151,15 +152,12 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
{
wxString name;
NETCLASS* myclass = GetNetClass();
NETCLASSPTR myclass = GetNetClass();
if( myclass )
name = myclass->GetName();
else
{
BOARD* board = GetBoard();
name = NETCLASS::Default;
}
return name;
}
......@@ -142,7 +142,7 @@ public:
* Function GetNetClass
* returns the NETCLASS for this item.
*/
NETCLASS* GetNetClass() const;
boost::shared_ptr<NETCLASS> GetNetClass() const;
/**
* Function GetNetClassName
......
......@@ -176,7 +176,7 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( PARAM_CFG_ARRAY* aResult )
bool BOARD_DESIGN_SETTINGS::SetCurrentNetClass( const wxString& aNetClassName )
{
NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
NETCLASSPTR netClass = m_NetClasses.Find( aNetClassName );
bool lists_sizes_modified = false;
// if not found (should not happen) use the default
......@@ -229,7 +229,7 @@ int BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue()
//Read list of Net Classes
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
{
NETCLASS* netclass = nc->second;
NETCLASSPTR netclass = nc->second;
clearance = std::max( clearance, netclass->GetClearance() );
}
......@@ -244,7 +244,7 @@ int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue()
//Read list of Net Classes
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
{
NETCLASS* netclass = nc->second;
NETCLASSPTR netclass = nc->second;
clearance = std::min( clearance, netclass->GetClearance() );
}
......@@ -254,7 +254,7 @@ int BOARD_DESIGN_SETTINGS::GetSmallestClearanceValue()
int BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize()
{
NETCLASS* netclass = m_NetClasses.Find( m_currentNetClassName );
NETCLASSPTR netclass = m_NetClasses.Find( m_currentNetClassName );
return netclass->GetuViaDiameter();
}
......@@ -262,7 +262,7 @@ int BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize()
int BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill()
{
NETCLASS* netclass = m_NetClasses.Find( m_currentNetClassName );
NETCLASSPTR netclass = m_NetClasses.Find( m_currentNetClassName );
return netclass->GetuViaDrill();
}
......
......@@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <boost/make_shared.hpp>
#include <fctsys.h>
#include <common.h>
......@@ -84,52 +85,25 @@ NETCLASS::~NETCLASS()
}
NETCLASSES::NETCLASSES() :
m_Default( NETCLASS::Default )
NETCLASSES::NETCLASSES()
{
m_Default = boost::make_shared<NETCLASS>( NETCLASS::Default );
}
NETCLASSES::~NETCLASSES()
{
Clear();
}
void NETCLASSES::Clear()
{
// Although std::map<> will destroy the items that it contains, in this
// case we have NETCLASS* (pointers) and "destroying" a pointer does not
// delete the object that the pointer points to.
// this NETCLASSES is owner of its NETCLASS pointers,
// so delete NETCLASSes pointed to by them.
for( iterator i = begin(); i!=end(); )
{
// http://www.sgi.com/tech/stl/Map.html says:
// "Erasing an element from a map also does not invalidate any iterators,
// except, of course, for iterators that actually point to the element that
// is being erased."
iterator e = i++; // copy, then advance.
delete e->second; // delete the NETCLASS, which 'second' points to.
m_NetClasses.erase( e );
}
}
bool NETCLASSES::Add( NETCLASS* aNetClass )
bool NETCLASSES::Add( NETCLASSPTR aNetClass )
{
const wxString& name = aNetClass->GetName();
if( name == NETCLASS::Default )
{
// invoke operator=(), which is currently generated by compiler.
m_Default = *aNetClass;
delete aNetClass; // we own aNetClass, must delete it since we copied it.
m_Default = aNetClass;
return true;
}
......@@ -139,6 +113,7 @@ bool NETCLASSES::Add( NETCLASS* aNetClass )
{
// name not found, take ownership
m_NetClasses[name] = aNetClass;
return true;
}
else
......@@ -150,30 +125,30 @@ bool NETCLASSES::Add( NETCLASS* aNetClass )
}
NETCLASS* NETCLASSES::Remove( const wxString& aNetName )
NETCLASSPTR NETCLASSES::Remove( const wxString& aNetName )
{
NETCLASSMAP::iterator found = m_NetClasses.find( aNetName );
if( found != m_NetClasses.end() )
{
NETCLASS* netclass = found->second;
boost::shared_ptr<NETCLASS> netclass = found->second;
m_NetClasses.erase( found );
return netclass;
}
return NULL;
return NETCLASSPTR();
}
NETCLASS* NETCLASSES::Find( const wxString& aName ) const
NETCLASSPTR NETCLASSES::Find( const wxString& aName ) const
{
if( aName == NETCLASS::Default )
return (NETCLASS*) &m_Default;
return m_Default;
NETCLASSMAP::const_iterator found = m_NetClasses.find( aName );
if( found == m_NetClasses.end() )
return NULL;
return NETCLASSPTR();
else
return found->second;
}
......@@ -197,9 +172,9 @@ void BOARD::SynchronizeNetsAndNetClasses()
// and therefore bogus netclass memberships will be deleted in logic below this loop.
for( NETCLASSES::iterator clazz = netClasses.begin(); clazz != netClasses.end(); ++clazz )
{
NETCLASS* netclass = clazz->second;
NETCLASSPTR netclass = clazz->second;
for( NETCLASS::iterator member = netclass->begin(); member != netclass->end(); ++member )
for( NETCLASS::const_iterator member = netclass->begin(); member != netclass->end(); ++member )
{
const wxString& netname = *member;
......@@ -222,7 +197,7 @@ void BOARD::SynchronizeNetsAndNetClasses()
for( NETCLASSES::iterator clazz = netClasses.begin(); clazz != netClasses.end(); ++clazz )
{
NETCLASS* netclass = clazz->second;
NETCLASSPTR netclass = clazz->second;
netclass->Clear();
}
......@@ -236,7 +211,7 @@ void BOARD::SynchronizeNetsAndNetClasses()
// because of the std:map<> this should be fast, and because of
// prior logic, netclass should not be NULL.
NETCLASS* netclass = netClasses.Find( classname );
NETCLASSPTR netclass = netClasses.Find( classname );
wxASSERT( netclass );
......
......@@ -33,6 +33,7 @@
#include <set>
#include <map>
#include <boost/shared_ptr.hpp>
#include <wx/string.h>
......@@ -210,6 +211,7 @@ public:
#endif
};
typedef boost::shared_ptr<NETCLASS> NETCLASSPTR;
/**
* Class NETCLASSES
......@@ -220,13 +222,13 @@ public:
class NETCLASSES
{
private:
typedef std::map<wxString, NETCLASS*> NETCLASSMAP;
typedef std::map<wxString, NETCLASSPTR> NETCLASSMAP;
/// all the NETCLASSes except the default one.
NETCLASSMAP m_NetClasses;
/// the default NETCLASS.
NETCLASS m_Default;
NETCLASSPTR m_Default;
public:
NETCLASSES();
......@@ -236,7 +238,10 @@ public:
* Function Clear
* destroys any contained NETCLASS instances except the Default one.
*/
void Clear();
void Clear()
{
m_NetClasses.clear();
}
typedef NETCLASSMAP::iterator iterator;
iterator begin() { return m_NetClasses.begin(); }
......@@ -259,9 +264,9 @@ public:
* Function GetDefault
* @return the default net class.
*/
NETCLASS* GetDefault() const
NETCLASSPTR GetDefault() const
{
return (NETCLASS*) &m_Default;
return m_Default;
}
/**
......@@ -271,24 +276,23 @@ public:
* @return true if the name within aNetclass is unique and it could be inserted OK,
* else false because the name was not unique and caller still owns aNetclass.
*/
bool Add( NETCLASS* aNetclass );
bool Add( NETCLASSPTR aNetclass );
/**
* Function Remove
* removes a NETCLASS from this container but does not destroy/delete it.
* @param aNetName is the name of the net to delete, and it may not be NETCLASS::Default.
* @return NETCLASS* - the NETCLASS associated with aNetName if found and removed, else NULL.
* You have to delete the returned value if you intend to destroy the NETCLASS.
* @return NETCLASSPTR - the NETCLASS associated with aNetName if found and removed, else NULL.
*/
NETCLASS* Remove( const wxString& aNetName );
NETCLASSPTR Remove( const wxString& aNetName );
/**
* Function Find
* searches this container for a NETCLASS given by \a aName.
* @param aName is the name of the NETCLASS to search for.
* @return NETCLASS* - if found, else NULL.
* @return NETCLASSPTR - if found, else NULL.
*/
NETCLASS* Find( const wxString& aName ) const;
NETCLASSPTR Find( const wxString& aName ) const;
};
......
......@@ -452,7 +452,7 @@ private:
wxString m_NetClassName; // Net Class name. if void this is equivalent
// to "default" (the first
// item of the net classes list
NETCLASS* m_NetClass;
NETCLASSPTR m_NetClass;
BOARD_ITEM* m_parent; ///< The parent board item object the net belongs to.
......@@ -474,9 +474,9 @@ public:
* Function SetClass
* sets \a aNetclass into this NET
*/
void SetClass( const NETCLASS* aNetClass )
void SetClass( NETCLASSPTR aNetClass )
{
m_NetClass = (NETCLASS*) aNetClass;
m_NetClass = aNetClass;
if( aNetClass )
m_NetClassName = aNetClass->GetName();
......@@ -484,7 +484,7 @@ public:
m_NetClassName = NETCLASS::Default;
}
NETCLASS* GetNetClass()
NETCLASSPTR GetNetClass()
{
return m_NetClass;
}
......@@ -630,7 +630,7 @@ public:
// general buffer of ratsnest
m_RatsnestEndIdx = 0; // Ending point of ratsnests of this net
SetClass( NULL );
SetClass( NETCLASSPTR() );
}
};
......
......@@ -58,7 +58,6 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent, const wxString& aNetName, int a
m_RatsnestEndIdx = 0; // Ending point of ratsnests of this net
m_NetClassName = NETCLASS::Default;
m_NetClass = NULL;
}
......
......@@ -226,7 +226,7 @@ int VIA::GetDrillValue() const
return m_Drill;
// Use the default value from the Netclass
NETCLASS* netclass = GetNetClass();
NETCLASSPTR netclass = GetNetClass();
if( GetViaType() == VIA_MICROVIA )
return netclass->GetuViaDrill();
......@@ -1008,7 +1008,7 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
}
}
NETCLASS* netclass = GetNetClass();
NETCLASSPTR netclass = GetNetClass();
if( netclass )
{
......
......@@ -548,7 +548,7 @@ int ZONE_CONTAINER::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
// "zone clearance" setting in the zone properties dialog. (At least
// until there is a UI boolean for this.)
NETCLASS* myClass = GetNetClass();
NETCLASSPTR myClass = GetNetClass();
if( myClass )
myClearance = std::max( myClearance, myClass->GetClearance() );
......
......@@ -46,6 +46,8 @@
#include <wx/generic/gridctrl.h>
#include <dialog_design_rules_aux_helper_class.h>
#include <boost/make_shared.hpp>
// Column labels for net lists
#define NET_TITLE _( "Net" )
#define CLASS_TITLE _( "Class" )
......@@ -221,10 +223,10 @@ void DIALOG_DESIGN_RULES::InitDialogRules()
// @todo go fix m_Pcb->SynchronizeNetsAndNetClasses() so that the netcode==0 is not present in the BOARD::m_NetClasses
NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
NETCLASS* netclass = netclasses.GetDefault();
NETCLASSPTR netclass = netclasses.GetDefault();
// Initialize list of nets for Default Net Class
for( NETCLASS::const_iterator name = netclass->begin(); name != netclass->end(); ++name )
for( NETCLASS::iterator name = netclass->begin(); name != netclass->end(); ++name )
{
m_AllNets.push_back( NETCUP( *name, netclass->GetName() ) );
}
......@@ -446,7 +448,7 @@ void DIALOG_DESIGN_RULES::InitializeRulesSelectionBoxes()
/* Initialize the rules list from board
*/
static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc )
static void class2gridRow( wxGrid* grid, int row, NETCLASSPTR nc )
{
wxString msg;
......@@ -494,14 +496,14 @@ void DIALOG_DESIGN_RULES::InitRulesList()
int row = 1;
for( NETCLASSES::iterator i = netclasses.begin(); i!=netclasses.end(); ++i, ++row )
{
NETCLASS* netclass = i->second;
NETCLASSPTR netclass = i->second;
class2gridRow( m_grid, row, netclass );
}
}
static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc )
static void gridRow2class( wxGrid* grid, int row, NETCLASSPTR nc )
{
#define MYCELL( col ) \
ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
......@@ -530,7 +532,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
// Copy other NetClasses :
for( int row = 1; row < m_grid->GetNumberRows(); ++row )
{
NETCLASS* nc = new NETCLASS( m_grid->GetRowLabelValue( row ) );
NETCLASSPTR nc = boost::make_shared<NETCLASS>( m_grid->GetRowLabelValue( row ) );
if( !m_BrdSettings->m_NetClasses.Add( nc ) )
{
......@@ -540,7 +542,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
msg.Printf( wxT( "CopyRulesListToBoard(): The NetClass \"%s\" already exists. Skip" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
wxMessageBox( msg );
delete nc;
continue;
}
......@@ -550,7 +552,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
// Now read all nets and push them in the corresponding netclass net buffer
for( NETCUPS::const_iterator netcup = m_AllNets.begin(); netcup != m_AllNets.end(); ++netcup )
{
NETCLASS* nc = netclasses.Find( netcup->clazz );
NETCLASSPTR nc = netclasses.Find( netcup->clazz );
wxASSERT( nc );
nc->Add( netcup->net );
}
......
......@@ -48,7 +48,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::MyInit()
BOARD* board = m_Parent->GetBoard();
BOARD_DESIGN_SETTINGS& dsnSettings = board->GetDesignSettings();
NETCLASSES& netclasses = dsnSettings.m_NetClasses;
NETCLASS* netclass = netclasses.GetDefault();
NETCLASSPTR netclass = netclasses.GetDefault();
NETINFO_ITEM* net = board->FindNet( m_Netcode );
if( net )
......
......@@ -295,7 +295,7 @@ void DRC::updatePointers()
}
bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
bool DRC::doNetClass( NETCLASSPTR nc, wxString& msg )
{
bool ret = true;
......@@ -412,7 +412,7 @@ bool DRC::testNetClasses()
for( NETCLASSES::const_iterator i = netclasses.begin(); i != netclasses.end(); ++i )
{
NETCLASS* nc = i->second;
NETCLASSPTR nc = i->second;
if( !doNetClass( nc, msg ) )
ret = false;
......
......@@ -153,7 +153,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
int net_code_ref;
wxPoint shape_pos;
NETCLASS* netclass = aRefSeg->GetNetClass();
NETCLASSPTR netclass = aRefSeg->GetNetClass();
BOARD_DESIGN_SETTINGS& dsnSettings = m_pcb->GetDesignSettings();
/* In order to make some calculations more easier or faster,
......
......@@ -29,8 +29,8 @@
#ifndef _DRC_STUFF_H
#define _DRC_STUFF_H
#include <vector>
#include <boost/shared_ptr.hpp>
#define OK_DRC 0
#define BAD_DRC 1
......@@ -283,7 +283,7 @@ private:
//-----<single "item" tests>-----------------------------------------
bool doNetClass( NETCLASS* aNetClass, wxString& msg );
bool doNetClass( boost::shared_ptr<NETCLASS> aNetClass, wxString& msg );
/**
* Function doPadToPadsDrc
......
......@@ -1146,7 +1146,7 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const
if( m_rules->mdWireWire )
{
NETCLASS* defaultNetclass = designSettings.GetDefault();
NETCLASSPTR defaultNetclass = designSettings.GetDefault();
int clearance = KiROUND( m_rules->mdWireWire );
if( clearance < defaultNetclass->GetClearance() )
......
......@@ -685,7 +685,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
if ( g_FirstTrackSegment == NULL )
return;
NETCLASS* netclass = g_FirstTrackSegment->GetNetClass();
NETCLASSPTR netclass = g_FirstTrackSegment->GetNetClass();
if( showTrackClearanceMode != DO_NOT_SHOW_CLEARANCE )
DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS;
......
......@@ -86,6 +86,8 @@
#include <trigo.h>
#include <build_version.h>
#include <boost/make_shared.hpp>
typedef LEGACY_PLUGIN::BIU BIU;
......@@ -632,7 +634,7 @@ void LEGACY_PLUGIN::loadSHEET()
void LEGACY_PLUGIN::loadSETUP()
{
NETCLASS* netclass_default = m_board->GetDesignSettings().GetDefault();
NETCLASSPTR netclass_default = m_board->GetDesignSettings().GetDefault();
// TODO Orson: is it really necessary to first operate on a copy and then apply it?
// would not it be better to use reference here and apply all the changes instantly?
BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings();
......@@ -2113,7 +2115,7 @@ void LEGACY_PLUGIN::loadNETCLASS()
// yet since that would bypass duplicate netclass name checking within the BOARD.
// store it temporarily in an auto_ptr until successfully inserted into the BOARD
// just before returning.
auto_ptr<NETCLASS> nc( new NETCLASS( wxEmptyString ) );
NETCLASSPTR nc = boost::make_shared<NETCLASS>( wxEmptyString );
while( ( line = READLINE( m_reader ) ) != NULL )
{
......@@ -2175,11 +2177,7 @@ void LEGACY_PLUGIN::loadNETCLASS()
else if( TESTLINE( "$EndNCLASS" ) )
{
if( m_board->GetDesignSettings().m_NetClasses.Add( nc.get() ) )
{
nc.release();
}
else
if( !m_board->GetDesignSettings().m_NetClasses.Add( nc ) )
{
// Must have been a name conflict, this is a bad board file.
// User may have done a hand edit to the file.
......@@ -2985,7 +2983,7 @@ void LEGACY_PLUGIN::saveSHEET( const BOARD* aBoard ) const
void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const
{
const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
NETCLASS* netclass_default = bds.GetDefault();
NETCLASSPTR netclass_default = bds.GetDefault();
fprintf( m_fp, "$SETUP\n" );
......@@ -3170,7 +3168,7 @@ void LEGACY_PLUGIN::saveNETCLASSES( const NETCLASSES* aNetClasses ) const
// the rest will be alphabetical in the *.brd file.
for( NETCLASSES::const_iterator it = aNetClasses->begin(); it != aNetClasses->end(); ++it )
{
NETCLASS* netclass = it->second;
NETCLASSPTR netclass = it->second;
saveNETCLASS( netclass );
}
......@@ -3178,7 +3176,7 @@ void LEGACY_PLUGIN::saveNETCLASSES( const NETCLASSES* aNetClasses ) const
}
void LEGACY_PLUGIN::saveNETCLASS( const NETCLASS* nc ) const
void LEGACY_PLUGIN::saveNETCLASS( const NETCLASSPTR nc ) const
{
fprintf( m_fp, "$NCLASS\n" );
fprintf( m_fp, "Name %s\n", EscapedUTF8( nc->GetName() ).c_str() );
......
......@@ -26,6 +26,7 @@
*/
#include <io_mgr.h>
#include <boost/shared_ptr.hpp>
#include <string>
......@@ -256,7 +257,7 @@ protected:
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
void saveNETCLASSES( const NETCLASSES* aNetClasses ) const;
void saveNETCLASS( const NETCLASS* aNetclass ) const;
void saveNETCLASS( const boost::shared_ptr<NETCLASS> aNetclass ) const;
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
void savePCB_TARGET( const PCB_TARGET* aTarget ) const;
......
......@@ -51,6 +51,8 @@
#include <zones.h>
#include <pcb_parser.h>
#include <boost/make_shared.hpp>
void PCB_PARSER::init()
{
......@@ -808,7 +810,7 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as setup." ) );
T token;
NETCLASS* defaultNetClass = m_board->GetDesignSettings().GetDefault();
NETCLASSPTR defaultNetClass = m_board->GetDesignSettings().GetDefault();
// TODO Orson: is it really necessary to first operate on a copy and then apply it?
// would not it be better to use reference here and apply all the changes instantly?
BOARD_DESIGN_SETTINGS designSettings = m_board->GetDesignSettings();
......@@ -1082,7 +1084,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR )
T token;
std::auto_ptr<NETCLASS> nc( new NETCLASS( wxEmptyString ) );
NETCLASSPTR nc = boost::make_shared<NETCLASS>( wxEmptyString );
// Read netclass name (can be a name or just a number like track width)
NeedSYMBOLorNUMBER();
......@@ -1135,11 +1137,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR )
NeedRIGHT();
}
if( m_board->GetDesignSettings().m_NetClasses.Add( nc.get() ) )
{
nc.release();
}
else
if( !m_board->GetDesignSettings().m_NetClasses.Add( nc ) )
{
// Must have been a name conflict, this is a bad board file.
// User may have done a hand edit to the file.
......
......@@ -72,7 +72,7 @@ public:
continue;
wxString netClassName = ni->GetClassName();
NETCLASS* nc = aBoard->GetDesignSettings().m_NetClasses.Find( netClassName );
NETCLASSPTR nc = aBoard->GetDesignSettings().m_NetClasses.Find( netClassName );
int clearance = nc->GetClearance();
m_clearanceCache[i] = clearance;
TRACE( 1, "Add net %d netclass %s clearance %d", i % netClassName.mb_str() %
......
......@@ -269,7 +269,7 @@ int& aViaDiameter, int& aViaDrill )
BOARD* board = getModel<BOARD>( PCB_T );
BOARD_DESIGN_SETTINGS &bds = board->GetDesignSettings();
NETCLASS* netClass = NULL;
NETCLASSPTR netClass;
NETINFO_ITEM* ni = board->FindNet( aNetCode );
if( ni )
......
......@@ -31,6 +31,7 @@
// see http://www.boost.org/libs/ptr_container/doc/ptr_set.html
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/shared_ptr.hpp>
#include <fctsys.h>
#include <specctra_lexer.h>
......@@ -3813,7 +3814,7 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
* Function exportNETCLASS
* exports \a aNetClass to the DSN file.
*/
void exportNETCLASS( NETCLASS* aNetClass, BOARD* aBoard );
void exportNETCLASS( boost::shared_ptr<NETCLASS> aNetClass, BOARD* aBoard );
//-----</FromBOARD>------------------------------------------------------
......
......@@ -1476,7 +1476,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
//-----<rules>--------------------------------------------------------
{
char rule[80];
NETCLASS* defaultClass = aBoard->GetDesignSettings().m_NetClasses.GetDefault();
NETCLASSPTR defaultClass = aBoard->GetDesignSettings().GetDefault();
int defaultTrackWidth = defaultClass->GetTrackWidth();
int defaultClearance = defaultClass->GetClearance();
......@@ -1854,7 +1854,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
// Add the via from the Default netclass first. The via container
// in pcb->library preserves the sequence of addition.
NETCLASS* netclass = nclasses.GetDefault();
NETCLASSPTR netclass = nclasses.GetDefault();
PADSTACK* via = makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
m_top_via_layer, m_bot_via_layer );
......@@ -2046,13 +2046,13 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
for( NETCLASSES::iterator nc = nclasses.begin(); nc != nclasses.end(); ++nc )
{
NETCLASS* netclass = nc->second;
NETCLASSPTR netclass = nc->second;
exportNETCLASS( netclass, aBoard );
}
}
void SPECCTRA_DB::exportNETCLASS( NETCLASS* aNetClass, BOARD* aBoard )
void SPECCTRA_DB::exportNETCLASS( NETCLASSPTR aNetClass, BOARD* aBoard )
{
/* From page 11 of specctra spec:
*
......
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