From aa3e2988905fd893c6c85d10d65533904557a5bd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 18 Jul 2023 11:19:52 +0200 Subject: [PATCH] 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 --- kicad/kicad_manager_frame.cpp | 56 ++++++++++++------- kicad/kicad_manager_frame.h | 2 + kicad/tools/kicad_manager_control.cpp | 3 + .../dialogs/dialog_global_edit_teardrops.cpp | 5 +- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 984b2d77ef..9d29f6e3f0 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -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( - [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( + [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(); } } diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index a74aea651c..b3a82bdec1 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -153,6 +153,8 @@ public: void SetPcmButton( BITMAP_BUTTON* aButton ); + void CreatePCM(); // creates the PLUGIN_CONTENT_MANAGER + DECLARE_EVENT_TABLE() protected: diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index ec727f957b..52ff75cda9 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -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(); diff --git a/pcbnew/dialogs/dialog_global_edit_teardrops.cpp b/pcbnew/dialogs/dialog_global_edit_teardrops.cpp index 229d810e00..0bcb062d36 100644 --- a/pcbnew/dialogs/dialog_global_edit_teardrops.cpp +++ b/pcbnew/dialogs/dialog_global_edit_teardrops.cpp @@ -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 );