Fix some issues with Font property
Prevent out-of-bounds access Make sure list is initialized in symbol editor frame Don't re-init the list more frequently than necessary Fixes https://gitlab.com/kicad/code/kicad/-/issues/16399
This commit is contained in:
parent
3f73bbcc4f
commit
7470ec80e4
|
@ -857,7 +857,10 @@ void EDA_TEXT::SetFontIndex( int aIdx )
|
|||
std::vector<std::string> fontNames;
|
||||
Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ) );
|
||||
|
||||
SetFont( KIFONT::FONT::GetFont( fontNames[ aIdx ], IsBold(), IsItalic() ) );
|
||||
if( aIdx >= 0 && aIdx < static_cast<int>( fontNames.size() ) )
|
||||
SetFont( KIFONT::FONT::GetFont( fontNames[ aIdx ], IsBold(), IsItalic() ) );
|
||||
else
|
||||
SetFont( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,11 @@ public:
|
|||
|
||||
virtual void AfterCommit() {}
|
||||
|
||||
/**
|
||||
* Parents will call this when the user changes the UI language
|
||||
*/
|
||||
virtual void LanguageChanged() {}
|
||||
|
||||
wxPropertyGrid* GetPropertyGrid()
|
||||
{
|
||||
return m_grid;
|
||||
|
|
|
@ -1912,6 +1912,8 @@ void SCH_EDIT_FRAME::ShowChangedLanguage()
|
|||
m_auimgr.Update();
|
||||
m_hierarchy->UpdateHierarchyTree();
|
||||
|
||||
m_propertiesPanel->LanguageChanged();
|
||||
|
||||
// status bar
|
||||
UpdateMsgPanel();
|
||||
|
||||
|
|
|
@ -1250,6 +1250,8 @@ void SYMBOL_EDIT_FRAME::ShowChangedLanguage()
|
|||
|
||||
m_treePane->GetLibTree()->ShowChangedLanguage();
|
||||
|
||||
m_propertiesPanel->LanguageChanged();
|
||||
|
||||
// status bar
|
||||
UpdateMsgPanel();
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ SCH_PROPERTIES_PANEL::SCH_PROPERTIES_PANEL( wxWindow* aParent, SCH_BASE_FRAME* a
|
|||
{
|
||||
m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( it->second );
|
||||
}
|
||||
|
||||
updateFontList();
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,10 +104,6 @@ void SCH_PROPERTIES_PANEL::UpdateData()
|
|||
EE_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
||||
const SELECTION& selection = selectionTool->GetSelection();
|
||||
|
||||
// TODO perhaps it could be called less often? use PROPERTIES_TOOL and catch MODEL_RELOAD?
|
||||
if( SCH_EDIT_FRAME* schFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
|
||||
updateLists( schFrame->Schematic() );
|
||||
|
||||
// Will actually just be updatePropertyValues() if selection hasn't changed
|
||||
rebuildProperties( selection );
|
||||
}
|
||||
|
@ -209,7 +207,13 @@ void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SCH_PROPERTIES_PANEL::updateLists( const SCHEMATIC& aSchematic )
|
||||
void SCH_PROPERTIES_PANEL::LanguageChanged()
|
||||
{
|
||||
updateFontList();
|
||||
}
|
||||
|
||||
|
||||
void SCH_PROPERTIES_PANEL::updateFontList()
|
||||
{
|
||||
wxPGChoices fonts;
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
void AfterCommit() override;
|
||||
|
||||
void LanguageChanged() override;
|
||||
|
||||
protected:
|
||||
wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const override;
|
||||
|
||||
|
@ -51,8 +53,8 @@ protected:
|
|||
void valueChanging( wxPropertyGridEvent& aEvent ) override;
|
||||
void valueChanged( wxPropertyGridEvent& aEvent ) override;
|
||||
|
||||
///< Regenerates caches of list properties
|
||||
void updateLists( const SCHEMATIC& aSchematic );
|
||||
///< Regenerates caches of font list property
|
||||
void updateFontList();
|
||||
|
||||
SCH_BASE_FRAME* m_frame;
|
||||
PROPERTY_MANAGER& m_propMgr;
|
||||
|
|
Loading…
Reference in New Issue