7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-02 00:26:45 +00:00

Speed up shutdown

When shutting down, we shouldn't need to do a lot of things like
resyncing the PNS world multiple times that can really slow down the
process
This commit is contained in:
Seth Hillbrand 2024-07-03 15:01:52 -07:00
parent ae5678f3f6
commit c0bf866c58
9 changed files with 33 additions and 8 deletions

View File

@ -56,12 +56,14 @@ COMMON_TOOLS::COMMON_TOOLS() :
void COMMON_TOOLS::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
m_grids.clear();
if( aReason == RESET_REASON::SHUTDOWN )
return;
GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid;
EDA_IU_SCALE scale = m_frame->GetIuScale();
m_grids.clear();
for( GRID& gridDef : settings.grids )
{
double gridSizeX = EDA_UNIT_UTILS::UI::DoubleValueFromString( scale, EDA_UNITS::MILLIMETRES,

View File

@ -78,7 +78,7 @@ void EE_INSPECTION_TOOL::Reset( RESET_REASON aReason )
{
EE_TOOL_BASE::Reset( aReason );
if( aReason == SUPERMODEL_RELOAD )
if( aReason == SUPERMODEL_RELOAD || aReason == RESET_REASON::SHUTDOWN )
{
wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY );

View File

@ -357,6 +357,9 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
m_selection.Clear();
}
if( aReason == RESET_REASON::SHUTDOWN )
return;
if( aReason == TOOL_BASE::MODEL_RELOAD || aReason == TOOL_BASE::SUPERMODEL_RELOAD )
{
getView()->GetPainter()->GetSettings()->SetHighlight( false );

View File

@ -142,7 +142,7 @@ void GERBVIEW_SELECTION_TOOL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<GERBVIEW_FRAME>();
if( aReason == TOOL_BASE::MODEL_RELOAD )
if( aReason == TOOL_BASE::MODEL_RELOAD || aReason == RESET_REASON::SHUTDOWN )
{
// Remove pointers to the selected items from containers
// without changing their properties (as they are already deleted

View File

@ -80,7 +80,8 @@ public:
MODEL_RELOAD, ///< Model changes (the sheet for a schematic)
SUPERMODEL_RELOAD, ///< For schematics, the entire schematic changed, not just the sheet
GAL_SWITCH, ///< Rendering engine changes
REDRAW ///< Full drawing refresh
REDRAW, ///< Full drawing refresh
SHUTDOWN ///< Tool is being shut down
};
/**

View File

@ -90,7 +90,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool doAskAboutUnsavedChanges, bool aFinal )
else if( m_isClosing )
{
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
m_toolManager->ResetTools( TOOL_BASE::SHUTDOWN );
// Clear the view so we don't attempt redraws (particularly of the RATSNEST_VIEW_ITEM,
// which causes all manner of grief).
@ -145,10 +145,10 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool doAskAboutUnsavedChanges )
// Setup our own severities for the Footprint Checker.
// These are not (at present) user-editable.
std::map<int, SEVERITY>& drcSeverities = GetBoard()->GetDesignSettings().m_DRCSeverities;
for( int errorCode = DRCE_FIRST; errorCode <= DRCE_LAST; ++errorCode )
drcSeverities[ errorCode ] = RPT_SEVERITY_ERROR;
drcSeverities[ DRCE_DRILLED_HOLES_COLOCATED ] = RPT_SEVERITY_WARNING;
drcSeverities[ DRCE_DRILLED_HOLES_TOO_CLOSE ] = RPT_SEVERITY_WARNING;

View File

@ -75,6 +75,14 @@ void TOOL_BASE::Reset( RESET_REASON aReason )
delete m_router;
delete m_iface; // Delete after m_router because PNS::NODE dtor needs m_ruleResolver
if( aReason == RESET_REASON::SHUTDOWN )
{
m_gridHelper = nullptr;
m_router = nullptr;
m_iface = nullptr;
return;
}
m_iface = new PNS_KICAD_IFACE;
m_iface->SetBoard( board() );
m_iface->SetView( getView() );

View File

@ -293,6 +293,9 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
// Re-initialize session attributes
const BOARD_DESIGN_SETTINGS& bds = m_frame->GetDesignSettings();
if( aReason == RESET_REASON::SHUTDOWN )
return;
m_layer = m_frame->GetActiveLayer();
m_stroke.SetWidth( bds.GetLineThickness( m_layer ) );
m_stroke.SetLineStyle( LINE_STYLE::DEFAULT );

View File

@ -128,6 +128,14 @@ void GENERATOR_TOOL_PNS_PROXY::Reset( RESET_REASON aReason )
delete m_router;
delete m_iface; // Delete after m_router because PNS::NODE dtor needs m_ruleResolver
if( aReason == RESET_REASON::SHUTDOWN )
{
m_iface = nullptr;
m_router = nullptr;
m_gridHelper = nullptr;
return;
}
m_iface = new PNS_KICAD_IFACE_GENERATOR;
m_iface->SetBoard( board() );
m_iface->SetView( getView() );