Kicad manager: build the PLUGIN_CONTENT_MANAGER only un request, not in

KICAD_MANAGER_FRAME Ctor. Two advantages:
- it is built after the splash screen is dismissed.
- if there are issues when creating the PLUGIN_CONTENT_MANAGER, this is more
easy to debug
This commit is contained in:
jean-pierre charras 2023-07-18 11:19:52 +02:00
parent da1e82d57e
commit aa3e298890
4 changed files with 43 additions and 23 deletions

View File

@ -167,25 +167,6 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
m_pcmButton = nullptr;
m_pcmUpdateCount = 0;
m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
[this]( int aUpdateCount )
{
m_pcmUpdateCount = aUpdateCount;
CallAfter(
[this]()
{
updatePcmButtonBadge();
} );
},
[this]( const wxString aText )
{
CallAfter(
[aText, this]()
{
SetStatusText( aText, 1 );
} );
} );
m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
// Left window: is the box which display tree project
m_leftWin = new PROJECT_TREE_PANE( this );
@ -269,7 +250,8 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
if( m_toolManager )
m_toolManager->ShutdownAllTools();
m_pcm->StopBackgroundUpdate();
if( m_pcm )
m_pcm->StopBackgroundUpdate();
delete m_actions;
delete m_toolManager;
@ -279,6 +261,35 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
}
void KICAD_MANAGER_FRAME::CreatePCM()
{
// creates the PLUGIN_CONTENT_MANAGER, if not exists
if( m_pcm )
return;
m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
[this]( int aUpdateCount )
{
m_pcmUpdateCount = aUpdateCount;
CallAfter(
[this]()
{
updatePcmButtonBadge();
} );
},
[this]( const wxString aText )
{
CallAfter(
[aText, this]()
{
SetStatusText( aText, 1 );
} );
} );
m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
}
void KICAD_MANAGER_FRAME::setupTools()
{
// Create the manager
@ -754,7 +765,7 @@ void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex
{
EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
if( aEnvVarsChanged )
if( m_pcm && aEnvVarsChanged )
{
m_pcm->ReadEnvVar();
}
@ -920,6 +931,9 @@ void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
if( KIPLATFORM::POLICY::GetPolicyBool( POLICY_KEY_PCM ) != KIPLATFORM::POLICY::PBOOL::DISABLED
&& settings->m_PcmUpdateCheck )
{
if( !m_pcm )
CreatePCM();
m_pcm->RunBackgroundUpdate();
}
}

View File

@ -153,6 +153,8 @@ public:
void SetPcmButton( BITMAP_BUTTON* aButton );
void CreatePCM(); // creates the PLUGIN_CONTENT_MANAGER
DECLARE_EVENT_TABLE()
protected:

View File

@ -900,6 +900,9 @@ int KICAD_MANAGER_CONTROL::ShowPluginManager( const TOOL_EVENT& aEvent )
m_frame->SetFocus();
wxSafeYield();
if( !m_frame->GetPcm() )
m_frame->CreatePCM();
DIALOG_PCM pcm( m_frame, m_frame->GetPcm() );
pcm.ShowModal();

View File

@ -473,12 +473,13 @@ bool DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow()
}
// If there are no filters then a force-full-update is equivalent, and will be faster.
if( !m_netFilterOpt->GetValue()
if( 1 /*&&!m_netFilterOpt->GetValue()
&& !m_netclassFilterOpt->GetValue()
&& !m_layerFilterOpt->GetValue()
&& !m_roundPadsFilter->GetValue()
&& !m_existingFilter->GetValue()
&& !m_selectedItemsFilter->GetValue() )
&& !m_selectedItemsFilter->GetValue()*/
)
{
commit.Push( _( "Edit Teardrops" ), SKIP_TEARDROPS );