mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Nullptr safety; performance; formatting.
This commit is contained in:
parent
96dd1815ea
commit
f3050bd7ed
@ -119,8 +119,8 @@ private:
|
||||
|
||||
PANEL_TOOLBAR_CUSTOMIZATION::PANEL_TOOLBAR_CUSTOMIZATION( wxWindow* aParent, APP_SETTINGS_BASE* aCfg,
|
||||
TOOLBAR_SETTINGS* aTbSettings,
|
||||
std::vector<TOOL_ACTION*> aTools,
|
||||
std::vector<ACTION_TOOLBAR_CONTROL*> aControls ) :
|
||||
const std::vector<TOOL_ACTION*>& aTools,
|
||||
const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls ) :
|
||||
PANEL_TOOLBAR_CUSTOMIZATION_BASE( aParent ),
|
||||
m_actionImageList( nullptr ),
|
||||
m_appSettings( aCfg ),
|
||||
@ -244,14 +244,14 @@ bool PANEL_TOOLBAR_CUSTOMIZATION::TransferDataFromWindow()
|
||||
m_appSettings->m_CustomToolbars = m_customToolbars->GetValue();
|
||||
|
||||
// Store the current toolbar
|
||||
auto currentTb = parseToolbarTree();
|
||||
std::optional<TOOLBAR_CONFIGURATION> currentTb = parseToolbarTree();
|
||||
|
||||
if( currentTb.has_value() )
|
||||
m_toolbars[m_currentToolbar] = currentTb.value();
|
||||
|
||||
// Write the shadow toolbars with changes back to the app toolbar settings
|
||||
for( auto& tb : m_toolbars )
|
||||
m_appTbSettings->SetStoredToolbarConfig( tb.first, tb.second );
|
||||
for( const auto& [loc, config] : m_toolbars )
|
||||
m_appTbSettings->SetStoredToolbarConfig( loc, config );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -361,7 +361,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree()
|
||||
|
||||
wxTreeItemId root = m_toolbarTree->AddRoot( "Toolbar" );
|
||||
|
||||
for( auto& item : toolbar.GetToolbarItems() )
|
||||
for( const TOOLBAR_ITEM& item : toolbar.GetToolbarItems() )
|
||||
{
|
||||
switch( item.m_Type )
|
||||
{
|
||||
@ -388,8 +388,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree()
|
||||
// Add a control
|
||||
TOOLBAR_TREE_ITEM_DATA* controlTreeItem = new TOOLBAR_TREE_ITEM_DATA( TOOLBAR_ITEM_TYPE::CONTROL );
|
||||
controlTreeItem->SetName( item.m_ControlName );
|
||||
m_toolbarTree->AppendItem( root, item.m_ControlName, -1, -1,
|
||||
controlTreeItem );
|
||||
m_toolbarTree->AppendItem( root, item.m_ControlName, -1, -1, controlTreeItem );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -413,8 +412,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree()
|
||||
if( imgMap != m_actionImageListMap.end() )
|
||||
imgIdx = imgMap->second;
|
||||
|
||||
m_toolbarTree->AppendItem( root, toolMap->second->GetFriendlyName(),
|
||||
imgIdx, -1, toolTreeItem );
|
||||
m_toolbarTree->AppendItem( root, toolMap->second->GetFriendlyName(), imgIdx, -1, toolTreeItem );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -428,7 +426,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree()
|
||||
groupTreeItem );
|
||||
|
||||
// Add the elements below the group
|
||||
for( auto& groupItem : item.m_GroupItems )
|
||||
for( const TOOLBAR_ITEM& groupItem : item.m_GroupItems )
|
||||
{
|
||||
auto toolMap = m_availableTools.find( groupItem.m_ActionName );
|
||||
|
||||
@ -450,6 +448,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateToolbarTree()
|
||||
m_toolbarTree->AppendItem( groupId, toolMap->second->GetFriendlyName(),
|
||||
imgIdx, -1, toolTreeItem );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -512,7 +511,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::populateActions()
|
||||
// Populate the various image lists for the action icons, and the actual control
|
||||
int itemIdx = 0;
|
||||
|
||||
for( auto [k, tool] : m_availableTools )
|
||||
for( const auto& [k, tool] : m_availableTools )
|
||||
{
|
||||
if( tool->CheckToolbarState( TOOLBAR_STATE::HIDDEN ) )
|
||||
continue;
|
||||
@ -760,7 +759,6 @@ void PANEL_TOOLBAR_CUSTOMIZATION::onBtnAddAction( wxCommandEvent& event )
|
||||
|
||||
if( selItem.IsOk() )
|
||||
{
|
||||
|
||||
TOOLBAR_TREE_ITEM_DATA* data =
|
||||
dynamic_cast<TOOLBAR_TREE_ITEM_DATA*>( m_toolbarTree->GetItemData( selItem ) );
|
||||
|
||||
@ -802,8 +800,9 @@ void PANEL_TOOLBAR_CUSTOMIZATION::onTreeBeginLabelEdit( wxTreeEvent& event )
|
||||
if( id.IsOk() )
|
||||
{
|
||||
wxTreeItemData* treeData = m_toolbarTree->GetItemData( id );
|
||||
TOOLBAR_TREE_ITEM_DATA* tbData = dynamic_cast<TOOLBAR_TREE_ITEM_DATA*>( treeData );
|
||||
|
||||
if( TOOLBAR_TREE_ITEM_DATA* tbData = dynamic_cast<TOOLBAR_TREE_ITEM_DATA*>( treeData ) )
|
||||
{
|
||||
switch( tbData->GetType() )
|
||||
{
|
||||
case TOOLBAR_ITEM_TYPE::TOOL:
|
||||
@ -820,6 +819,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::onTreeBeginLabelEdit( wxTreeEvent& event )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PANEL_TOOLBAR_CUSTOMIZATION::onTreeEndLabelEdit( wxTreeEvent& event )
|
||||
@ -831,7 +831,7 @@ void PANEL_TOOLBAR_CUSTOMIZATION::onTreeEndLabelEdit( wxTreeEvent& event )
|
||||
void PANEL_TOOLBAR_CUSTOMIZATION::onTbChoiceSelect( wxCommandEvent& event )
|
||||
{
|
||||
// Store the current toolbar
|
||||
auto currentTb = parseToolbarTree();
|
||||
std::optional<TOOLBAR_CONFIGURATION> currentTb = parseToolbarTree();
|
||||
|
||||
if( currentTb.has_value() )
|
||||
m_toolbars[m_currentToolbar] = currentTb.value();
|
||||
|
@ -40,8 +40,8 @@ class PANEL_TOOLBAR_CUSTOMIZATION : public PANEL_TOOLBAR_CUSTOMIZATION_BASE
|
||||
{
|
||||
public:
|
||||
PANEL_TOOLBAR_CUSTOMIZATION( wxWindow* aParent, APP_SETTINGS_BASE* aCfg, TOOLBAR_SETTINGS* aTbSettings,
|
||||
std::vector<TOOL_ACTION*> aTools,
|
||||
std::vector<ACTION_TOOLBAR_CONTROL*> aControls );
|
||||
const std::vector<TOOL_ACTION*>& aTools,
|
||||
const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls );
|
||||
|
||||
~PANEL_TOOLBAR_CUSTOMIZATION();
|
||||
|
||||
|
@ -427,7 +427,8 @@ typedef std::function<void ( ACTION_TOOLBAR* )> ACTION_TOOLBAR_CONTROL_FACTORY;
|
||||
class ACTION_TOOLBAR_CONTROL
|
||||
{
|
||||
public:
|
||||
ACTION_TOOLBAR_CONTROL( std::string aName, wxString aUiName, wxString aDescription ) :
|
||||
ACTION_TOOLBAR_CONTROL( const std::string& aName, const wxString& aUiName,
|
||||
const wxString& aDescription ) :
|
||||
m_name( aName ),
|
||||
m_uiname( aUiName ),
|
||||
m_description( aDescription )
|
||||
|
@ -235,7 +235,7 @@ public:
|
||||
/**
|
||||
* Set the stored configuration for the given toolbar.
|
||||
*/
|
||||
void SetStoredToolbarConfig( TOOLBAR_LOC aToolbar, TOOLBAR_CONFIGURATION& aConfig )
|
||||
void SetStoredToolbarConfig( TOOLBAR_LOC aToolbar, const TOOLBAR_CONFIGURATION& aConfig )
|
||||
{
|
||||
m_toolbars[aToolbar] = aConfig;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user