Fix const-reference property access.

Fixes https://gitlab.com/kicad/code/kicad/issues/12639
This commit is contained in:
Jeff Young 2022-10-15 19:36:08 +01:00
parent b109136c5c
commit 73e1676bdb
2 changed files with 22 additions and 11 deletions

View File

@ -2848,11 +2848,10 @@ static struct FOOTPRINT_DESC
&FOOTPRINT::SetLayer, &FOOTPRINT::GetLayer ); &FOOTPRINT::SetLayer, &FOOTPRINT::GetLayer );
layer->SetChoices( fpLayers ); layer->SetChoices( fpLayers );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer ); propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer );
/*
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Reference" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Reference" ),
&FOOTPRINT::SetReference, &FOOTPRINT::GetReference ) ); &FOOTPRINT::SetReference, &FOOTPRINT::GetReferenceAsString ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Value" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Value" ),
&FOOTPRINT::SetValue, &FOOTPRINT::GetValue ) );*/ &FOOTPRINT::SetValue, &FOOTPRINT::GetValueAsString ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Orientation" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Orientation" ),
&FOOTPRINT::SetOrientationDegrees, &FOOTPRINT::GetOrientationDegrees, &FOOTPRINT::SetOrientationDegrees, &FOOTPRINT::GetOrientationDegrees,
PROPERTY_DISPLAY::PT_DEGREE ) ); PROPERTY_DISPLAY::PT_DEGREE ) );
@ -2864,13 +2863,13 @@ static struct FOOTPRINT_DESC
PROPERTY_DISPLAY::PT_SIZE ) ); PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Solderpaste Margin Ratio Override" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, double>( _HKI( "Solderpaste Margin Ratio Override" ),
&FOOTPRINT::SetLocalSolderPasteMarginRatio, &FOOTPRINT::SetLocalSolderPasteMarginRatio,
&FOOTPRINT::GetLocalSolderPasteMarginRatio ) ); /* &FOOTPRINT::GetLocalSolderPasteMarginRatio ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library ID" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Library ID" ),
&FOOTPRINT::SetFPIDAsString, &FOOTPRINT::GetFPIDAsString ) ); &FOOTPRINT::SetFPIDAsString, &FOOTPRINT::GetFPIDAsString ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Description" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Description" ),
&FOOTPRINT::SetDescription, &FOOTPRINT::GetDescription ) ); &FOOTPRINT::SetDescription, &FOOTPRINT::GetDescription ) );
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Keywords" ), propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Keywords" ),
&FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) );*/ &FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) );
// TODO zone connection // TODO zone connection
} }
} _FOOTPRINT_DESC; } _FOOTPRINT_DESC;

View File

@ -207,13 +207,13 @@ public:
const LIB_ID& GetFPID() const { return m_fpid; } const LIB_ID& GetFPID() const { return m_fpid; }
void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; } void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
const wxString GetFPIDAsString() const { return m_fpid.Format(); } wxString GetFPIDAsString() const { return m_fpid.Format(); }
void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); } void SetFPIDAsString( const wxString& aFPID ) { m_fpid.Parse( aFPID ); }
const wxString& GetDescription() const { return m_doc; } wxString GetDescription() const { return m_doc; }
void SetDescription( const wxString& aDoc ) { m_doc = aDoc; } void SetDescription( const wxString& aDoc ) { m_doc = aDoc; }
const wxString& GetKeywords() const { return m_keywords; } wxString GetKeywords() const { return m_keywords; }
void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; } void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
const KIID_PATH& GetPath() const { return m_path; } const KIID_PATH& GetPath() const { return m_path; }
@ -530,6 +530,12 @@ public:
m_reference->SetText( aReference ); m_reference->SetText( aReference );
} }
// Property system doesn't like const references
wxString GetReferenceAsString() const
{
return GetReference();
}
/** /**
* Bump the current reference by \a aDelta. * Bump the current reference by \a aDelta.
*/ */
@ -551,6 +557,12 @@ public:
m_value->SetText( aValue ); m_value->SetText( aValue );
} }
// Property system doesn't like const references
wxString GetValueAsString() const
{
return GetValue();
}
/// read/write accessors: /// read/write accessors:
FP_TEXT& Value() { return *m_value; } FP_TEXT& Value() { return *m_value; }
FP_TEXT& Reference() { return *m_reference; } FP_TEXT& Reference() { return *m_reference; }