Fix order of initializing tools when loading board
Also add a few safeguards against invalid situations Fixes https://gitlab.com/kicad/code/kicad/-/issues/5801
This commit is contained in:
parent
56ca842ec4
commit
b6e4b7bf7d
|
@ -1335,8 +1335,9 @@ void BOARD::SynchronizeProperties()
|
||||||
|
|
||||||
void BOARD::SynchronizeNetsAndNetClasses()
|
void BOARD::SynchronizeNetsAndNetClasses()
|
||||||
{
|
{
|
||||||
if( m_project )
|
if( !m_project )
|
||||||
{
|
return;
|
||||||
|
|
||||||
NET_SETTINGS* netSettings = m_project->GetProjectFile().m_NetSettings.get();
|
NET_SETTINGS* netSettings = m_project->GetProjectFile().m_NetSettings.get();
|
||||||
NETCLASSES& netClasses = netSettings->m_NetClasses;
|
NETCLASSES& netClasses = netSettings->m_NetClasses;
|
||||||
NETCLASSPTR defaultNetClass = netClasses.GetDefault();
|
NETCLASSPTR defaultNetClass = netClasses.GetDefault();
|
||||||
|
@ -1367,7 +1368,6 @@ void BOARD::SynchronizeNetsAndNetClasses()
|
||||||
bds.SetCustomDiffPairWidth( defaultNetClass->GetDiffPairWidth() );
|
bds.SetCustomDiffPairWidth( defaultNetClass->GetDiffPairWidth() );
|
||||||
bds.SetCustomDiffPairGap( defaultNetClass->GetDiffPairGap() );
|
bds.SetCustomDiffPairGap( defaultNetClass->GetDiffPairGap() );
|
||||||
bds.SetCustomDiffPairViaGap( defaultNetClass->GetDiffPairViaGap() );
|
bds.SetCustomDiffPairViaGap( defaultNetClass->GetDiffPairViaGap() );
|
||||||
}
|
|
||||||
|
|
||||||
InvokeListeners( &BOARD_LISTENER::OnBoardNetSettingsChanged, *this );
|
InvokeListeners( &BOARD_LISTENER::OnBoardNetSettingsChanged, *this );
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,8 +142,21 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
|
||||||
|
|
||||||
PCB_BASE_FRAME::SetBoard( aBoard );
|
PCB_BASE_FRAME::SetBoard( aBoard );
|
||||||
|
|
||||||
|
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().m_GridOrigin ) );
|
||||||
|
|
||||||
|
// update the tool manager with the new board and its view.
|
||||||
|
if( m_toolManager )
|
||||||
|
{
|
||||||
|
GetCanvas()->DisplayBoard( aBoard );
|
||||||
|
|
||||||
|
GetCanvas()->UpdateColors();
|
||||||
|
m_toolManager->SetEnvironment( aBoard, GetCanvas()->GetView(),
|
||||||
|
GetCanvas()->GetViewControls(), config(), this );
|
||||||
|
|
||||||
if( new_board )
|
if( new_board )
|
||||||
{
|
{
|
||||||
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||||
|
|
||||||
BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
||||||
bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
|
bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
|
||||||
|
|
||||||
|
@ -157,20 +170,6 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
|
||||||
// wait till they run DRC or do an Inspect Clearance. Not sure which is better....
|
// wait till they run DRC or do an Inspect Clearance. Not sure which is better....
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().m_GridOrigin ) );
|
|
||||||
|
|
||||||
// update the tool manager with the new board and its view.
|
|
||||||
if( m_toolManager )
|
|
||||||
{
|
|
||||||
GetCanvas()->DisplayBoard( aBoard );
|
|
||||||
|
|
||||||
GetCanvas()->UpdateColors();
|
|
||||||
m_toolManager->SetEnvironment( aBoard, GetCanvas()->GetView(),
|
|
||||||
GetCanvas()->GetViewControls(), config(), this );
|
|
||||||
|
|
||||||
if( new_board )
|
|
||||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void DRC_TOOL::Reset( RESET_REASON aReason )
|
||||||
m_drcEngine = m_pcb->GetDesignSettings().m_DRCEngine;
|
m_drcEngine = m_pcb->GetDesignSettings().m_DRCEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aReason == MODEL_RELOAD )
|
if( aReason == MODEL_RELOAD && m_pcb->GetProject() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1882,6 +1882,10 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
COLOR_SETTINGS* theme = m_frame->GetColorSettings();
|
COLOR_SETTINGS* theme = m_frame->GetColorSettings();
|
||||||
COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
|
COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
|
||||||
|
|
||||||
|
// If the board isn't fully loaded, we can't yet rebuild
|
||||||
|
if( !board->GetProject() )
|
||||||
|
return;
|
||||||
|
|
||||||
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
||||||
m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue