From 06dcb64ad88492e9f49a6058db8a19de0f69a91c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Jun 2025 12:43:31 +0100 Subject: [PATCH] Harden progress reporter API against misuse. Also, titles are nouns, not verbs. (Messages *inside* reporters are verbs.) Also implements progress reporter for Altium schematic import. --- common/git/git_progress.h | 4 +- common/widgets/footprint_select_widget.cpp | 4 +- common/widgets/panel_design_block_chooser.cpp | 9 ++- common/widgets/wx_progress_reporters.cpp | 10 +++- cvpcb/cvpcb_mainframe.cpp | 2 +- eeschema/dialogs/dialog_schematic_setup.cpp | 8 +-- eeschema/files-io.cpp | 11 ++-- eeschema/sch_io/altium/sch_io_altium.cpp | 21 ++++++- eeschema/sch_io/altium/sch_io_altium.h | 59 ++++++++++--------- eeschema/symbol_editor/symbol_edit_frame.cpp | 4 +- eeschema/symbol_tree_model_adapter.cpp | 5 +- eeschema/symbol_viewer_frame.cpp | 5 +- gerbview/files.cpp | 3 +- include/widgets/wx_progress_reporters.h | 9 ++- kicad/dialogs/panel_jobset.cpp | 8 +-- .../dialogs/dialog_manage_repositories.cpp | 2 +- kicad/pcm/dialogs/panel_packages_view.cpp | 5 +- kicad/pcm/pcm.cpp | 2 +- kicad/project_tree_pane.cpp | 14 ++--- kicad/tools/kicad_manager_control.cpp | 3 +- pcbnew/autorouter/autoplace_tool.cpp | 13 ++-- pcbnew/dialogs/dialog_board_setup.cpp | 2 +- pcbnew/files.cpp | 8 +-- pcbnew/footprint_edit_frame.cpp | 4 +- pcbnew/tools/pcb_control.cpp | 2 +- pcbnew/tools/zone_filler_tool.cpp | 10 ++-- pcbnew/widgets/panel_footprint_chooser.cpp | 4 +- .../pcb_design_block_preview_widget.cpp | 2 +- pcbnew/zone_manager/dialog_zone_manager.cpp | 2 +- 29 files changed, 131 insertions(+), 104 deletions(-) diff --git a/common/git/git_progress.h b/common/git/git_progress.h index 47b9adbf9a..27239a2f24 100644 --- a/common/git/git_progress.h +++ b/common/git/git_progress.h @@ -31,12 +31,12 @@ class GIT_PROGRESS { public: - GIT_PROGRESS() : m_previousProgress( 0 ) + GIT_PROGRESS() : + m_previousProgress( 0 ) { m_progressReporter.reset(); } - void SetProgressReporter( std::unique_ptr aProgressReporter ) { m_progressReporter = std::move( aProgressReporter ); diff --git a/common/widgets/footprint_select_widget.cpp b/common/widgets/footprint_select_widget.cpp index da109d7ce0..be1f46f571 100644 --- a/common/widgets/footprint_select_widget.cpp +++ b/common/widgets/footprint_select_widget.cpp @@ -62,10 +62,12 @@ void FOOTPRINT_SELECT_WIDGET::Load( KIWAY& aKiway, PROJECT& aProject ) if( m_fp_list->GetCount() == 0 ) { + WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Load Footprint Libraries" ), 1, + PR_CAN_ABORT ); + // If the fp-info-cache is empty (or, more likely, hasn't been created in a new // project yet), load footprints the hard way. FP_LIB_TABLE* fpTable = aProject.PcbFootprintLibs( aKiway ); - WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Loading Footprint Libraries" ), 1 ); FOOTPRINT_LIST_IMPL& fpList = static_cast( *m_fp_list ); fpList.ReadFootprintFiles( fpTable, nullptr, &progressReporter ); diff --git a/common/widgets/panel_design_block_chooser.cpp b/common/widgets/panel_design_block_chooser.cpp index b2649ed3f0..b7e7736404 100644 --- a/common/widgets/panel_design_block_chooser.cpp +++ b/common/widgets/panel_design_block_chooser.cpp @@ -68,8 +68,9 @@ PANEL_DESIGN_BLOCK_CHOOSER::PANEL_DESIGN_BLOCK_CHOOSER( EDA_DRAW_FRAME* aFrame, DESIGN_BLOCK_LIB_TABLE* libs = m_frame->Prj().DesignBlockLibs(); // Load design block files: - WX_PROGRESS_REPORTER* progressReporter = - new WX_PROGRESS_REPORTER( aParent, _( "Loading Design Block Libraries" ), 1 ); + auto* progressReporter = new WX_PROGRESS_REPORTER( aParent, _( "Load Design Block Libraries" ), 1, + PR_CAN_ABORT ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadDesignBlockFiles( libs, nullptr, progressReporter ); // Force immediate deletion of the WX_PROGRESS_REPORTER. Do not use Destroy(), or use @@ -270,7 +271,9 @@ void PANEL_DESIGN_BLOCK_CHOOSER::RefreshLibs( bool aProgress ) // Sync FOOTPRINT_INFO list to the libraries on disk if( aProgress ) { - WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Design Block Libraries" ), 2 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Update Design Block Libraries" ), 2, + PR_CAN_ABORT ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadDesignBlockFiles( fpTable, nullptr, &progressReporter ); progressReporter.Show( false ); } diff --git a/common/widgets/wx_progress_reporters.cpp b/common/widgets/wx_progress_reporters.cpp index 96fb9070d6..5dd9a504f4 100644 --- a/common/widgets/wx_progress_reporters.cpp +++ b/common/widgets/wx_progress_reporters.cpp @@ -30,16 +30,18 @@ WX_PROGRESS_REPORTER::WX_PROGRESS_REPORTER( wxWindow* aParent, const wxString& aTitle, - int aNumPhases, bool aCanAbort, + int aNumPhases, int aCanAbort, bool aReserveSpaceForMessage ) : PROGRESS_REPORTER_BASE( aNumPhases ), - wxProgressDialog( aTitle, ( aReserveSpaceForMessage ? wxT( " " ) : wxT( "" ) ), 1, aParent, + wxProgressDialog( aTitle, + ( aReserveSpaceForMessage ? wxT( " " ) : wxT( "" ) ), + 1, aParent, // wxPD_APP_MODAL | // Don't use; messes up OSX when called from // quasi-modal dialog wxPD_AUTO_HIDE | // *MUST* use; otherwise wxWidgets will spin // up another event loop on completion which // causes all sorts of grief - ( aCanAbort ? wxPD_CAN_ABORT : 0 ) | wxPD_ELAPSED_TIME ), + aCanAbort | wxPD_ELAPSED_TIME ), m_appProgressIndicator( aParent ), m_messageWidth( 0 ) { @@ -85,6 +87,8 @@ bool WX_PROGRESS_REPORTER::updateUI() Fit(); } + Raise(); + m_messageChanged = false; } diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index cb65c74b73..88d6050825 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -900,7 +900,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() return false; } - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Load Footprint Libraries" ), 1, PR_CAN_ABORT ); m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter ); diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index 2829c4ece4..ed401d250a 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -252,10 +252,10 @@ void DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction( wxCommandEvent& event ) wxFileName schematicFn( projectFn ); schematicFn.SetExt( FILEEXT::KiCadSchematicFileExtension ); - wxString fullFileName = schematicFn.GetFullPath(); - wxString msg; - IO_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) ); - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Bus Aliases" ), 1 ); + wxString fullFileName = schematicFn.GetFullPath(); + wxString msg; + IO_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Load Bus Aliases" ), 1, PR_CAN_ABORT ); pi->SetProgressReporter( &progressReporter ); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 6662ccda49..bab4ee0905 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -155,8 +155,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SetStatusText( wxEmptyString ); m_infoBar->Dismiss(); - WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Creating Schematic" ) - : _( "Loading Schematic" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Create Schematic" ) + : _( "Load Schematic" ), 1, + PR_CAN_ABORT ); bool differentProject = pro.GetFullPath() != Prj().GetProjectFullName(); @@ -271,7 +272,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in try { { - wxBusyCursor busy; + wxBusyCursor busy; + WINDOW_DISABLER raii( this ); + Schematic().SetRoot( pi->LoadSchematicFile( fullFileName, &Schematic() ) ); // Make ${SHEETNAME} work on the root sheet until we properly support @@ -1335,7 +1338,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType, { IO_RELEASER pi( SCH_IO_MGR::FindPlugin( fileType ) ); DIALOG_HTML_REPORTER errorReporter( this ); - WX_PROGRESS_REPORTER progressReporter( this, _( "Importing Schematic" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Import Schematic" ), 1, PR_CAN_ABORT ); if( PROJECT_CHOOSER_PLUGIN* c_pi = dynamic_cast( pi.get() ) ) { diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 5c1a436341..be6dcaf064 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -821,8 +822,22 @@ void SCH_IO_ALTIUM::CreateAliases() void SCH_IO_ALTIUM::ParseAltiumSch( const wxString& aFileName ) { + if( m_rootFilepath.IsEmpty() ) + m_rootFilepath = aFileName; + // Load path may be different from the project path. - wxFileName parentFileName = aFileName; + wxFileName parentFileName( aFileName ); + + if( m_progressReporter ) + { + wxFileName relative = parentFileName; + relative.MakeRelativeTo( m_rootFilepath ); + + m_progressReporter->Report( wxString::Format( _( "Importing %s" ), relative.GetFullPath() ) ); + + if( !m_progressReporter->KeepRefreshing() ) + THROW_IO_ERROR( _( "Open cancelled by user." ) ); + } if( isBinaryFile( aFileName ) ) { @@ -842,8 +857,8 @@ void SCH_IO_ALTIUM::ParseAltiumSch( const wxString& aFileName ) } catch( const std::exception& exc ) { - wxLogTrace( traceAltiumSch, wxS( "Unhandled exception in Altium schematic " - "parsers: %s." ), exc.what() ); + wxLogTrace( traceAltiumSch, wxS( "Unhandled exception in Altium schematic parser: %s." ), + exc.what() ); throw; } } diff --git a/eeschema/sch_io/altium/sch_io_altium.h b/eeschema/sch_io/altium/sch_io_altium.h index e886fdd597..9b4ec265fa 100644 --- a/eeschema/sch_io/altium/sch_io_altium.h +++ b/eeschema/sch_io/altium/sch_io_altium.h @@ -212,50 +212,51 @@ private: void fixupSymbolPinNameNumbers( SYMBOL* aSymbol ); + // Symbol caching + void ensureLoadedLibrary( const wxString& aLibraryPath, const std::map* aProperties ); + long long getLibraryTimestamp( const wxString& aLibraryPath ) const; + + static bool isBinaryFile( const wxString& aFileName ); + static bool isASCIIFile( const wxString& aFileName ); + static bool checkFileHeader( const wxString& aFileName ); + private: - SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded.. + wxString m_rootFilepath; // The file path of the root sheet being imported + SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded.. SCH_SHEET_PATH m_sheetPath; - SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded - wxString m_libName; // Library name to save symbols - bool m_isIntLib; // Flag to indicate Integrated Library + SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded + wxString m_libName; // Library name to save symbols + bool m_isIntLib; // Flag to indicate Integrated Library - IO_RELEASER m_pi; // Plugin to create KiCad symbol library. - std::unique_ptr> m_properties; // Library plugin properties. + IO_RELEASER m_pi; // Plugin to create KiCad symbol library. + std::unique_ptr> m_properties; // Library plugin properties. - std::unique_ptr m_currentTitleBlock; // Will be assigned at the end of parsing - // a sheet + std::unique_ptr m_currentTitleBlock; // Will be assigned at the end of parsing + // a sheet - VECTOR2I m_sheetOffset; - std::unique_ptr m_altiumSheet; - std::map m_symbols; - std::map m_sheets; - std::map m_libSymbols; // every symbol has its unique lib_symbol + VECTOR2I m_sheetOffset; + std::unique_ptr m_altiumSheet; + std::map m_symbols; + std::map m_sheets; + std::map m_libSymbols; // every symbol has its unique lib_symbol - std::map m_powerSymbols; - std::vector m_altiumStorage; + std::map m_powerSymbols; + std::vector m_altiumStorage; std::vector m_altiumAdditional; - std::map m_altiumComponents; - std::map m_altiumTemplates; - std::map m_altiumImplementationList; - std::vector m_altiumPortsCurrentSheet; // we require all connections first + std::map m_altiumComponents; + std::map m_altiumTemplates; + std::map m_altiumImplementationList; + std::vector m_altiumPortsCurrentSheet; // we require all connections first // parse harness ports after "FileHeader" was parsed, in 2nd run. - std::vector m_altiumHarnessPortsCurrentSheet; - std::map m_altiumHarnesses; + std::vector m_altiumHarnessPortsCurrentSheet; + std::map m_altiumHarnesses; // Add offset to all harness ownerIndex'es after parsing FileHeader. int m_harnessOwnerIndexOffset; int m_harnessEntryParent; // used to identify harness connector for harness entry element - // Symbol caching - void ensureLoadedLibrary( const wxString& aLibraryPath, const std::map* aProperties ); - long long getLibraryTimestamp( const wxString& aLibraryPath ) const; - - static bool isBinaryFile( const wxString& aFileName ); - static bool isASCIIFile( const wxString& aFileName ); - static bool checkFileHeader( const wxString& aFileName ); - std::map m_timestamps; std::map> m_libCache; diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index b0d3e1440f..5968079dc9 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -147,8 +147,8 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : { // Preload libraries before using SyncLibraries the first time, as the preload is // multi-threaded - WX_PROGRESS_REPORTER reporter( this, _( "Loading Symbol Libraries" ), - m_libMgr->GetLibraryCount(), true ); + WX_PROGRESS_REPORTER reporter( this, _( "Load Symbol Libraries" ), m_libMgr->GetLibraryCount(), + PR_CAN_ABORT ); m_libMgr->Preload( reporter ); loadingCancelled = reporter.IsCancelled(); diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index b2c6233a2f..4ae5f833ec 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -70,9 +70,8 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector& aNick if( m_show_progress ) { - progressReporter = std::make_unique( aFrame, - _( "Loading Symbol Libraries" ), - aNicknames.size(), true ); + progressReporter = std::make_unique( aFrame, _( "Load Symbol Libraries" ), + aNicknames.size(), PR_CAN_ABORT ); } // Disable KIID generation: not needed for library parts; sometimes very slow diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 57a01f1f8d..ff56e9da49 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -274,9 +274,8 @@ void SYMBOL_VIEWER_FRAME::loadAllLibraries() if( m_show_progress ) { - progressReporter = std::make_unique( this, - _( "Loading Symbol Libraries" ), - libraryNames.size(), true ); + progressReporter = std::make_unique( this, _( "Load Symbol Libraries" ), + libraryNames.size(), PR_CAN_ABORT ); } // Disable KIID generation: not needed for library parts; sometimes very slow diff --git a/gerbview/files.cpp b/gerbview/files.cpp index f000955ca6..fdc7405057 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -300,8 +300,7 @@ bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath, if( !progress && ( aFilenameList.GetCount() > 1 ) ) { - progress = std::make_unique( this, _( "Loading files..." ), 1, - false ); + progress = std::make_unique( this, _( "Load Files" ), 1, PR_CAN_ABORT ); progress->SetMaxProgress( aFilenameList.GetCount() - 1 ); progress->Report( wxString::Format( _("Loading %u/%zu %s..." ), ii+1, diff --git a/include/widgets/wx_progress_reporters.h b/include/widgets/wx_progress_reporters.h index a75fbe6066..c2b4c528fc 100644 --- a/include/widgets/wx_progress_reporters.h +++ b/include/widgets/wx_progress_reporters.h @@ -33,6 +33,9 @@ #include +#define PR_NO_ABORT 0 +#define PR_CAN_ABORT wxPD_CAN_ABORT + /** * Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting * back of work status. @@ -53,12 +56,12 @@ public: * aNumPhases = 1 is the usual progress bar * aNumPhases = n creates n virtual progress bar zones: a 0 to 100 percent width * of a virtual zone fills 0 to 1/n progress bar full size of the nth virtual zone index - * @param aCanAbort is true if the abort button should be shown + * @param aCanAbort indicates if the Cancel button should be shown * @param aReserveSpaceForMessage will ensure that the dialog is laid out for status messages, * preventing layout issues on Windows when reporting a message after the initial layout */ - WX_PROGRESS_REPORTER( wxWindow* aParent, const wxString& aTitle, int aNumPhases, - bool aCanAbort = true, bool aReserveSpaceForMessage = true ); + WX_PROGRESS_REPORTER( wxWindow* aParent, const wxString& aTitle, int aNumPhases, int aCanAbort, + bool aReserveSpaceForMessage = true ); ~WX_PROGRESS_REPORTER(); /** diff --git a/kicad/dialogs/panel_jobset.cpp b/kicad/dialogs/panel_jobset.cpp index a8fea08628..1f773868b2 100644 --- a/kicad/dialogs/panel_jobset.cpp +++ b/kicad/dialogs/panel_jobset.cpp @@ -274,8 +274,8 @@ public: JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile, &project ); - auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), - 1 ); + auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Run Jobs" ), 1, + PR_NO_ABORT ); if( JOBSET_DESTINATION* destination = GetDestination() ) jobRunner.RunJobsForDestination( destination ); @@ -992,8 +992,8 @@ void PANEL_JOBSET::OnGenerateAllDestinationsClick( wxCommandEvent& event ) JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile.get(), &project ); - WX_PROGRESS_REPORTER* progressReporter = - new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 ); + auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Run Jobs" ), 1, + PR_NO_ABORT ); jobRunner.RunJobsAllDestinations(); diff --git a/kicad/pcm/dialogs/dialog_manage_repositories.cpp b/kicad/pcm/dialogs/dialog_manage_repositories.cpp index cf87bcc2f9..740200aaa1 100644 --- a/kicad/pcm/dialogs/dialog_manage_repositories.cpp +++ b/kicad/pcm/dialogs/dialog_manage_repositories.cpp @@ -127,7 +127,7 @@ void DIALOG_MANAGE_REPOSITORIES::addRepository( const wxString& aUrl ) } PCM_REPOSITORY repository; - WX_PROGRESS_REPORTER reporter( GetParent(), wxT( "" ), 1 ); + WX_PROGRESS_REPORTER reporter( GetParent(), wxT( "" ), 1, PR_CAN_ABORT ); if( m_pcm->FetchRepository( aUrl, repository, &reporter ) ) { diff --git a/kicad/pcm/dialogs/panel_packages_view.cpp b/kicad/pcm/dialogs/panel_packages_view.cpp index a901996fed..1bf8f9bbb4 100644 --- a/kicad/pcm/dialogs/panel_packages_view.cpp +++ b/kicad/pcm/dialogs/panel_packages_view.cpp @@ -539,10 +539,9 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event ) std::ofstream output( path.ToUTF8(), std::ios_base::binary ); - std::unique_ptr reporter = - std::make_unique( this, _( "Downloading package" ), 1 ); + WX_PROGRESS_REPORTER reporter( this, _( "Download Package" ), 1, PR_CAN_ABORT ); - bool success = m_pcm->DownloadToStream( url, &output, reporter.get(), 0 ); + bool success = m_pcm->DownloadToStream( url, &output, &reporter, 0 ); output.close(); diff --git a/kicad/pcm/pcm.cpp b/kicad/pcm/pcm.cpp index 3abc699284..584aa2618e 100644 --- a/kicad/pcm/pcm.cpp +++ b/kicad/pcm/pcm.cpp @@ -388,7 +388,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId ) std::shared_ptr reporter; if( m_dialog ) - reporter = std::make_shared( m_dialog, wxEmptyString, 1 ); + reporter = std::make_shared( m_dialog, wxT( "" ), 1, PR_CAN_ABORT ); else reporter = m_updateBackgroundJob->m_reporter; diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index ab1d23ed70..799599fc79 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -1789,9 +1789,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent ) GIT_PULL_HANDLER handler( m_TreeProject->GitCommon() ); - handler.SetProgressReporter( std::make_unique( this, - _( "Fetching Remote" ), - 1 ) ); + handler.SetProgressReporter( std::make_unique( this, _( "Fetch Remote" ), 1, PR_NO_ABORT ) ); handler.PerformFetch(); @@ -1823,9 +1821,8 @@ void PROJECT_TREE_PANE::onGitPullProject( wxCommandEvent& aEvent ) GIT_PULL_HANDLER handler( m_TreeProject->GitCommon() ); - handler.SetProgressReporter( std::make_unique( this, - _( "Fetching Remote" ), - 1 ) ); + handler.SetProgressReporter( std::make_unique( this, _( "Fetch Remote" ), 1, + PR_NO_ABORT ) ); if( handler.PerformPull() < PullResult::Success ) { @@ -1847,9 +1844,8 @@ void PROJECT_TREE_PANE::onGitPushProject( wxCommandEvent& aEvent ) GIT_PUSH_HANDLER handler( m_TreeProject->GitCommon() ); - handler.SetProgressReporter( std::make_unique( this, - _( "Fetching Remote" ), - 1 ) ); + handler.SetProgressReporter( std::make_unique( this, _( "Fetch Remote" ), 1, + PR_NO_ABORT ) ); if( handler.PerformPush() != PushResult::Success ) { diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index 5461ee1e1f..d50e40a80f 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -178,7 +178,8 @@ int KICAD_MANAGER_CONTROL::NewFromRepository( const TOOL_EVENT& aEvent ) cloneHandler.SetPassword( dlg.GetPassword() ); cloneHandler.SetSSHKey( dlg.GetRepoSSHPath() ); - cloneHandler.SetProgressReporter( std::make_unique( m_frame, _( "Cloning Repository" ), 1 ) ); + cloneHandler.SetProgressReporter( std::make_unique( m_frame, _( "Clone Repository" ), 1, + PR_NO_ABORT ) ); if( !cloneHandler.PerformClone() ) { diff --git a/pcbnew/autorouter/autoplace_tool.cpp b/pcbnew/autorouter/autoplace_tool.cpp index 4de747c35c..14f5ccd72b 100644 --- a/pcbnew/autorouter/autoplace_tool.cpp +++ b/pcbnew/autorouter/autoplace_tool.cpp @@ -77,8 +77,10 @@ int AUTOPLACE_TOOL::autoplace( std::vector& aFootprints ) } int locked_count = std::count_if( aFootprints.begin(), aFootprints.end(), - [](FOOTPRINT* fp) { return fp->IsLocked(); } ); - + [](FOOTPRINT* fp) + { + return fp->IsLocked(); + } ); PCBNEW_SETTINGS* settings = frame()->GetPcbNewSettings(); @@ -120,14 +122,13 @@ int AUTOPLACE_TOOL::autoplace( std::vector& aFootprints ) std::function callback = refreshCallback; autoplacer.SetRefreshCallback( callback ); - std::unique_ptr progressReporter = - std::make_unique( frame(), _( "Autoplace Components" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( frame(), _( "Autoplace Footprints" ), 1, PR_CAN_ABORT ); + autoplacer.SetProgressReporter( &progressReporter ); - autoplacer.SetProgressReporter( progressReporter.get() ); auto result = autoplacer.AutoplaceFootprints( aFootprints, &commit, false ); if( result == AR_COMPLETED ) - commit.Push( _( "Autoplace Components" ) ); + commit.Push( _( "Autoplace Footprints" ) ); else commit.Revert(); diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 2f59e5cb21..a9c3c9ec5f 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -351,7 +351,7 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent ) try { - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading PCB" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Load PCB" ), 1, PR_CAN_ABORT ); pi->SetProgressReporter( &progressReporter ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 8e824a228d..bfaa9bcb19 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -565,8 +565,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // Get rid of any existing warnings about the old board GetInfoBar()->Dismiss(); - WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Creating PCB" ) - : _( "Loading PCB" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Create PCB" ) : _( "Load PCB" ), 1, + PR_CAN_ABORT ); // No save prompt (we already prompted above), and only reset to a new blank board if new Clear_Pcb( false, !is_new ); @@ -1316,7 +1316,7 @@ int BOARD_EDITOR_CONTROL::GenIPC2581File( const TOOL_EVENT& aEvent ) wxString tempFile = wxFileName::CreateTempFileName( wxS( "pcbnew_ipc" ) ); wxString upperTxt; wxString lowerTxt; - WX_PROGRESS_REPORTER reporter( m_frame, _( "Generating IPC-2581 file" ), 5 ); + WX_PROGRESS_REPORTER reporter( m_frame, _( "Generate IPC-2581 File" ), 5, PR_CAN_ABORT ); std::map props; props["units"] = dlg.GetUnitsString(); @@ -1439,7 +1439,7 @@ int BOARD_EDITOR_CONTROL::GenerateODBPPFiles( const TOOL_EVENT& aEvent ) job.m_units = dlg.GetUnitsString() == "mm" ? JOB_EXPORT_PCB_ODB::ODB_UNITS::MM : JOB_EXPORT_PCB_ODB::ODB_UNITS::INCH; - WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Generating ODB++ output files" ), 3, false ); + WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Generate ODB++ Files" ), 3, PR_CAN_ABORT ); WX_STRING_REPORTER reporter; DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( job, m_frame->GetBoard(), m_frame, &progressReporter, &reporter ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index d6dc31fb4a..88b2d66e0f 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -1086,7 +1086,7 @@ void FOOTPRINT_EDIT_FRAME::initLibraryTree() { FP_LIB_TABLE* fpTable = PROJECT_PCB::PcbFootprintLibs( &Prj() ); - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Load Footprint Libraries" ), 1, PR_CAN_ABORT ); if( GFootprintList.GetCount() == 0 ) GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) ); @@ -1114,7 +1114,7 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress ) // Sync FOOTPRINT_INFO list to the libraries on disk if( aProgress ) { - WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Update Footprint Libraries" ), 1, PR_CAN_ABORT ); GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter ); progressReporter.Show( false ); } diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 9420456396..2330475ce2 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -1686,7 +1686,7 @@ int PCB_CONTROL::AppendBoard( PCB_IO& pi, const wxString& fileName, DESIGN_BLOCK return dlg.ShowModal() == wxID_OK; } ); - WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Load PCB" ), 1, PR_CAN_ABORT ); editFrame->GetDesignSettings().m_NetSettings->ClearNetclasses(); pi.SetProgressReporter( &progressReporter ); diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index 33a3eb01ea..f48d5d2016 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -86,7 +86,8 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep } else { - reporter = std::make_unique( aCaller, _( "Checking Zones" ), 4 ); + reporter = std::make_unique( aCaller, _( "Check Zones" ), 4, + PR_CAN_ABORT ); m_filler->SetProgressReporter( reporter.get() ); } @@ -163,7 +164,8 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo } else { - reporter = std::make_unique( aCaller, _( "Fill All Zones" ), 5 ); + reporter = std::make_unique( aCaller, _( "Fill All Zones" ), 5, + PR_CAN_ABORT ); m_filler->SetProgressReporter( reporter.get() ); } @@ -256,7 +258,7 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent ) { wxString title = wxString::Format( _( "Refill %d Zones" ), (int) toFill.size() ); - reporter = std::make_unique( frame, title, 5 ); + reporter = std::make_unique( frame, title, 5, PR_CAN_ABORT ); m_filler->SetProgressReporter( reporter.get() ); break; } @@ -347,7 +349,7 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent ) m_filler = std::make_unique( board(), &commit ); - reporter = std::make_unique( frame(), _( "Fill Zone" ), 5 ); + reporter = std::make_unique( frame(), _( "Fill Zone" ), 5, PR_CAN_ABORT ); m_filler->SetProgressReporter( reporter.get() ); if( m_filler->Fill( toFill ) ) diff --git a/pcbnew/widgets/panel_footprint_chooser.cpp b/pcbnew/widgets/panel_footprint_chooser.cpp index 8c06a9fed9..457a468397 100644 --- a/pcbnew/widgets/panel_footprint_chooser.cpp +++ b/pcbnew/widgets/panel_footprint_chooser.cpp @@ -67,8 +67,8 @@ PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopL FP_LIB_TABLE* fpTable = PROJECT_PCB::PcbFootprintLibs( &aFrame->Prj() ); // Load footprint files: - WX_PROGRESS_REPORTER* progressReporter = new WX_PROGRESS_REPORTER( aParent, - _( "Loading Footprint Libraries" ), 1 ); + auto* progressReporter = new WX_PROGRESS_REPORTER( aParent, _( "Load Footprint Libraries" ), 1, + PR_CAN_ABORT ); GFootprintList.ReadFootprintFiles( fpTable, nullptr, progressReporter ); // Force immediate deletion of the WX_PROGRESS_REPORTER. Do not use Destroy(), or use diff --git a/pcbnew/widgets/pcb_design_block_preview_widget.cpp b/pcbnew/widgets/pcb_design_block_preview_widget.cpp index 383f617d45..d5cd56d643 100644 --- a/pcbnew/widgets/pcb_design_block_preview_widget.cpp +++ b/pcbnew/widgets/pcb_design_block_preview_widget.cpp @@ -184,7 +184,7 @@ void PCB_DESIGN_BLOCK_PREVIEW_WIDGET::DisplayDesignBlock( DESIGN_BLOCK* aDesignB try { IO_RELEASER pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::KICAD_SEXP ) ); - WX_PROGRESS_REPORTER progressReporter( this, _( "Loading PCB" ), 1 ); + WX_PROGRESS_REPORTER progressReporter( this, _( "Load PCB" ), 1, PR_CAN_ABORT ); pi->SetProgressReporter( &progressReporter ); diff --git a/pcbnew/zone_manager/dialog_zone_manager.cpp b/pcbnew/zone_manager/dialog_zone_manager.cpp index c09174a712..8eea1c6fdf 100644 --- a/pcbnew/zone_manager/dialog_zone_manager.cpp +++ b/pcbnew/zone_manager/dialog_zone_manager.cpp @@ -387,7 +387,7 @@ void DIALOG_ZONE_MANAGER::OnUpdateDisplayedZonesClick( wxCommandEvent& aEvent ) auto commit = std::make_unique( m_pcbFrame ); m_filler = std::make_unique( board, commit.get() ); - auto reporter = std::make_unique( this, _( "Fill All Zones" ), 5 ); + auto reporter = std::make_unique( this, _( "Fill All Zones" ), 5, PR_CAN_ABORT ); m_filler->SetProgressReporter( reporter.get() ); // TODO: replace these const_cast calls with a different solution that avoids mutating the