From 73e1676bdbb156082c8e5a2db3248e070710468d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 15 Oct 2022 19:36:08 +0100 Subject: [PATCH] Fix const-reference property access. Fixes https://gitlab.com/kicad/code/kicad/issues/12639 --- pcbnew/footprint.cpp | 9 ++++----- pcbnew/footprint.h | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 617412ed09..6c709f3e29 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -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( _HKI( "Reference" ), - &FOOTPRINT::SetReference, &FOOTPRINT::GetReference ) ); + &FOOTPRINT::SetReference, &FOOTPRINT::GetReferenceAsString ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Value" ), - &FOOTPRINT::SetValue, &FOOTPRINT::GetValue ) );*/ + &FOOTPRINT::SetValue, &FOOTPRINT::GetValueAsString ) ); propMgr.AddProperty( new PROPERTY( _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( _HKI( "Solderpaste Margin Ratio Override" ), &FOOTPRINT::SetLocalSolderPasteMarginRatio, - &FOOTPRINT::GetLocalSolderPasteMarginRatio ) ); /* + &FOOTPRINT::GetLocalSolderPasteMarginRatio ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Library ID" ), &FOOTPRINT::SetFPIDAsString, &FOOTPRINT::GetFPIDAsString ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Description" ), &FOOTPRINT::SetDescription, &FOOTPRINT::GetDescription ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Keywords" ), - &FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) );*/ + &FOOTPRINT::SetKeywords, &FOOTPRINT::GetKeywords ) ); // TODO zone connection } } _FOOTPRINT_DESC; diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index cb91702ecd..0277992046 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -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& GetProperties() const { return m_properties; } + const std::map& GetProperties() const { return m_properties; } void SetProperties( const std::map& 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.