Fix some issues in PCM code.

Try to fix 9955, due to a problem with WX_PROGRESS_REPORTER (issue with its parent)
Fixes #9955
https://gitlab.com/kicad/code/kicad/issues/9955
This commit is contained in:
jean-pierre charras 2021-12-12 18:25:31 +01:00
parent 779629ad33
commit 0f728e4d67
2 changed files with 9 additions and 11 deletions

View File

@ -73,13 +73,14 @@ void DIALOG_MANAGE_REPOSITORIES::setColumnWidths()
void DIALOG_MANAGE_REPOSITORIES::OnAddButtonClicked( wxCommandEvent& event )
{
wxTextEntryDialog* entry_dialog = new wxTextEntryDialog(
this, _( "Please enter fully qualified repository url" ), _( "Add repository" ) );
wxTextEntryDialog entry_dialog( this,
_( "Please enter fully qualified repository url" ),
_( "Add repository" ) );
if( entry_dialog->ShowModal() == wxID_OK )
if( entry_dialog.ShowModal() == wxID_OK )
{
PCM_REPOSITORY repository;
wxString url = entry_dialog->GetValue();
wxString url = entry_dialog.GetValue();
const auto find_row = [&]( const int col, const wxString& val )
{
@ -100,10 +101,9 @@ void DIALOG_MANAGE_REPOSITORIES::OnAddButtonClicked( wxCommandEvent& event )
}
else
{
std::unique_ptr<WX_PROGRESS_REPORTER> reporter(
new WX_PROGRESS_REPORTER( this, wxT( "" ), 1 ) );
WX_PROGRESS_REPORTER reporter( GetParent(), wxT( "" ), 1 );
if( m_pcm->FetchRepository( url, repository, reporter.get() ) )
if( m_pcm->FetchRepository( url, repository, &reporter ) )
{
wxString name = repository.name;
int increment = 1;
@ -126,8 +126,6 @@ void DIALOG_MANAGE_REPOSITORIES::OnAddButtonClicked( wxCommandEvent& event )
}
}
}
entry_dialog->Destroy();
}

View File

@ -195,7 +195,7 @@ bool PCM_TASK_MANAGER::extract( const wxString& aFilePath, const wxString& aPack
for( ; entry; entry = zip.GetNextEntry() )
{
wxArrayString path_parts =
wxSplit( entry->GetName(), wxFileName::GetPathSeparator(), (wxChar) NULL );
wxSplit( entry->GetName(), wxFileName::GetPathSeparator(), (wxChar) 0 );
if( path_parts.size() < 2
|| PCM_PACKAGE_DIRECTORIES.find( path_parts[0] ) == PCM_PACKAGE_DIRECTORIES.end()
@ -215,7 +215,7 @@ bool PCM_TASK_MANAGER::extract( const wxString& aFilePath, const wxString& aPack
path_parts.Insert( clean_package_id, 1 );
path_parts.Insert( m_pcm->Get3rdPartyPath(), 0 );
wxString fullname = wxJoin( path_parts, wxFileName::GetPathSeparator(), (wxChar) NULL );
wxString fullname = wxJoin( path_parts, wxFileName::GetPathSeparator(), (wxChar) 0 );
// Ensure the target directory exists and create it if not.
wxString t_path = wxPathOnly( fullname );