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

View File

@ -207,13 +207,13 @@ public:
const LIB_ID& GetFPID() const { return m_fpid; }
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 ); }
const wxString& GetDescription() const { return m_doc; }
wxString GetDescription() const { return m_doc; }
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; }
const KIID_PATH& GetPath() const { return m_path; }
@ -530,6 +530,12 @@ public:
m_reference->SetText( aReference );
}
// Property system doesn't like const references
wxString GetReferenceAsString() const
{
return GetReference();
}
/**
* Bump the current reference by \a aDelta.
*/
@ -551,6 +557,12 @@ public:
m_value->SetText( aValue );
}
// Property system doesn't like const references
wxString GetValueAsString() const
{
return GetValue();
}
/// read/write accessors:
FP_TEXT& Value() { return *m_value; }
FP_TEXT& Reference() { return *m_reference; }
@ -559,14 +571,14 @@ public:
FP_TEXT& Value() const { return *m_value; }
FP_TEXT& Reference() const { return *m_reference; }
const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
bool HasProperty( const wxString& aKey)
{
return m_properties.find( aKey ) != m_properties.end();
}
void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
/**
* Return a #PAD with a matching number.