Commit ec7f26f5 authored by Dick Hollenbeck's avatar Dick Hollenbeck

FP_LIB_TABLE::ROW::SetFullURI() does environment variable substitution up front.

We can now remove a few calls to FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
since its being done in above function.

DIALOG_FP_LIB_TABLE now handles table to copy cut copy paste from global to
project and reverse.  Fixed a problem with cursor position management when
switching between tables.
parent 248788f3
...@@ -51,6 +51,13 @@ void FP_LIB_TABLE::ROW::SetType( const wxString& aType ) ...@@ -51,6 +51,13 @@ void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
} }
void FP_LIB_TABLE::ROW::SetFullURI( const wxString& aFullURI )
{
uri_user = aFullURI;
uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
}
FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) : FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
fallBack( aFallBackTable ) fallBack( aFallBackTable )
{ {
...@@ -407,7 +414,7 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRowByURI( const wxString& aURI ) ...@@ -407,7 +414,7 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRowByURI( const wxString& aURI )
for( unsigned i = 0; i < cur->rows.size(); i++ ) for( unsigned i = 0; i < cur->rows.size(); i++ )
{ {
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() ); wxString uri = cur->rows[i].GetFullURI( true );
if( wxFileName::GetPathSeparator() == wxChar( '\\' ) && uri.Find( wxChar( '/' ) ) >= 0 ) if( wxFileName::GetPathSeparator() == wxChar( '\\' ) && uri.Find( wxChar( '/' ) ) >= 0 )
uri.Replace( wxT( "/" ), wxT( "\\" ) ); uri.Replace( wxT( "/" ), wxT( "\\" ) );
...@@ -461,16 +468,17 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aLibraryNickName ...@@ -461,16 +468,17 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aLibraryNickName
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
/* enable this when FP_LIB_TABLE::Footprint*() functions are put into use. #if 0 // enable this as soon as FP_LIB_TABLE::FindRow() is not being used outside
// this class, and FP_LIB_TABLE::Footprint*() functions are put into use.
if( !row->plugin ) if( !row->plugin )
row->setPlugin( IO_MGR::PluginFind( row->type ) ); row->setPlugin( IO_MGR::PluginFind( row->type ) );
*/ #endif
return row; return row;
} }
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString aString ) const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
{ {
// We reserve the right to do this another way, by providing our own member // We reserve the right to do this another way, by providing our own member
// function. // function.
...@@ -604,7 +612,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL ...@@ -604,7 +612,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
for( unsigned i = 0; i < cur->rows.size(); i++ ) for( unsigned i = 0; i < cur->rows.size(); i++ )
{ {
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() ); wxString uri = cur->rows[i].GetFullURI( true );
if( wxFileName::GetPathSeparator() == wxChar( '\\' ) if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 ) && uri.Find( wxChar( '/' ) ) >= 0 )
...@@ -616,6 +624,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL ...@@ -616,6 +624,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
break; break;
} }
} }
} while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() ); } while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() );
if( libNickname.IsEmpty() ) if( libNickname.IsEmpty() )
......
...@@ -112,17 +112,18 @@ public: ...@@ -112,17 +112,18 @@ public:
ROW( const wxString& aNick, const wxString& aURI, const wxString& aType, ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
const wxString& aOptions, const wxString& aDescr = wxEmptyString ) : const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
nickName( aNick ), nickName( aNick ),
uri( aURI ),
options( aOptions ),
description( aDescr ), description( aDescr ),
properties( 0 ) properties( 0 )
{ {
SetOptions( aOptions ),
SetFullURI( aURI );
SetType( aType ); SetType( aType );
} }
ROW( const ROW& a ) : ROW( const ROW& a ) :
nickName( a.nickName ), nickName( a.nickName ),
uri( a.uri ), uri_user( a.uri_user ),
uri_expanded( a.uri_expanded ),
type( a.type ), type( a.type ),
options( a.options ), options( a.options ),
description( a.description ), description( a.description ),
...@@ -139,22 +140,23 @@ public: ...@@ -139,22 +140,23 @@ public:
ROW& operator=( const ROW& r ) ROW& operator=( const ROW& r )
{ {
nickName = r.nickName; nickName = r.nickName;
uri = r.uri; uri_user = r.uri_user;
type = r.type; uri_expanded = r.uri_expanded;
options = r.options; type = r.type;
options = r.options;
description = r.description;
properties = r.properties ? new PROPERTIES( *r.properties ) : NULL;
description = r.description; // do not copy the PLUGIN, it is lazily created.
properties = r.properties ? new PROPERTIES( *r.properties ) : NULL; // setPlugin( NULL );
setPlugin( NULL ); // do not copy the PLUGIN, it is lazily created.
return *this; return *this;
} }
bool operator==( const ROW& r ) const bool operator==( const ROW& r ) const
{ {
return nickName==r.nickName && uri==r.uri && type==r.type && options==r.options; return nickName==r.nickName && uri_user==r.uri_user && type==r.type && options==r.options;
} }
bool operator!=( const ROW& r ) const { return !( *this == r ); } bool operator!=( const ROW& r ) const { return !( *this == r ); }
...@@ -187,23 +189,24 @@ public: ...@@ -187,23 +189,24 @@ public:
/** /**
* Function GetFullURI * Function GetFullURI
* returns the full location specifying URI for the LIB. * returns the full location specifying URI for the LIB, either in original
* UI form or in environment variable expanded form.
* *
* @param doEnvVarSubs tells this function to do the substitution, else not. * @param aSubstituted Tells if caller wanted the substituted form, else not.
*/ */
const wxString GetFullURI( bool doEnvVarSubs = false ) const const wxString& GetFullURI( bool aSubstituted = false ) const
{ {
if( doEnvVarSubs ) if( aSubstituted )
return FP_LIB_TABLE::ExpandSubstitutions( uri ); return uri_expanded;
else else
return uri; return uri_user;
} }
/** /**
* Function SetFullURI * Function SetFullURI
* changes the full URI for the library. * changes the full URI for the library.
*/ */
void SetFullURI( const wxString& aFullURI ) { uri = aFullURI; } void SetFullURI( const wxString& aFullURI );
/** /**
* Function GetOptions * Function GetOptions
...@@ -274,7 +277,8 @@ public: ...@@ -274,7 +277,8 @@ public:
} }
wxString nickName; wxString nickName;
wxString uri; wxString uri_user; ///< what user entered from UI or loaded from disk
wxString uri_expanded; ///< from ExpandSubstitutions()
LIB_T type; LIB_T type;
wxString options; wxString options;
wxString description; wxString description;
...@@ -524,7 +528,7 @@ public: ...@@ -524,7 +528,7 @@ public:
* This enables (fp_lib_table)s to have platform dependent environment * This enables (fp_lib_table)s to have platform dependent environment
* variables in them, allowing for a uniform table across platforms. * variables in them, allowing for a uniform table across platforms.
*/ */
static const wxString ExpandSubstitutions( const wxString aString ); static const wxString ExpandSubstitutions( const wxString& aString );
/** /**
* Function LoadGlobalTable * Function LoadGlobalTable
......
This diff is collapsed.
...@@ -221,7 +221,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, ...@@ -221,7 +221,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
BOARD* aAppendToMe, const PROPERTIES* aProperties ) BOARD* aAppendToMe, const PROPERTIES* aProperties )
{ {
// release the PLUGIN even if an exception is thrown. // release the PLUGIN even if an exception is thrown.
PLUGIN::RELEASER pi = PluginFind( aFileType ); PLUGIN::RELEASER pi( PluginFind( aFileType ) );
if( (PLUGIN*) pi ) // test pi->plugin if( (PLUGIN*) pi ) // test pi->plugin
{ {
...@@ -235,7 +235,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, ...@@ -235,7 +235,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties ) void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{ {
// release the PLUGIN even if an exception is thrown. // release the PLUGIN even if an exception is thrown.
PLUGIN::RELEASER pi = PluginFind( aFileType ); PLUGIN::RELEASER pi( PluginFind( aFileType ) );
if( (PLUGIN*) pi ) // test pi->plugin if( (PLUGIN*) pi ) // test pi->plugin
{ {
......
...@@ -405,7 +405,11 @@ public: ...@@ -405,7 +405,11 @@ public:
API functions which take one. API functions which take one.
*/ */
virtual ~PLUGIN() {}; virtual ~PLUGIN()
{
//printf( "~%s", __func__ );
};
/** /**
* Class RELEASER * Class RELEASER
...@@ -419,6 +423,9 @@ public: ...@@ -419,6 +423,9 @@ public:
// private assignment operator so it's illegal // private assignment operator so it's illegal
RELEASER& operator=( RELEASER& aOther ) { return *this; } RELEASER& operator=( RELEASER& aOther ) { return *this; }
// private copy constructor so it's illegal
RELEASER( const RELEASER& aOther ) {}
public: public:
RELEASER( PLUGIN* aPlugin = NULL ) : RELEASER( PLUGIN* aPlugin = NULL ) :
plugin( aPlugin ) plugin( aPlugin )
......
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