Don't show busy cursor when dialogs (including progress) are in use.

Also removes a stale comment.
Also moves the progress reporters earlier to lessen need for busy cursor.
Also cleans up some error strings and makes other more easily translatable.
This commit is contained in:
Jeff Young 2021-06-26 20:17:34 +01:00
parent 310adedf85
commit 4c5df22eb0
2 changed files with 21 additions and 37 deletions

View File

@ -296,10 +296,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
return false;
}
// Loading a complex project and build data can be time
// consumming, so display a busy cursor
wxBusyCursor dummy;
// unload current project file before loading new
{
SetScreen( nullptr );
@ -310,17 +306,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetStatusText( wxEmptyString );
m_infoBar->Dismiss();
SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( fullFileName );
// PROJECT::SetProjectFullName() is an impactful function. It should only be
// called under carefully considered circumstances.
// The calling code should know not to ask me here to change projects unless
// it knows what consequences that will have on other KIFACEs running and using
// this same PROJECT. It can be very harmful if that calling code is stupid.
// NOTE: The calling code should never call this in hosted (non-standalone) mode with a
// different project than what has been loaded by the manager frame. This will crash.
WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Creating Schematic" )
: _( "Loading Schematic" ), 1 );
bool differentProject = pro.GetFullPath() != Prj().GetProjectFullName();
@ -345,6 +332,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
CreateScreens();
}
SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( fullFileName );
if( schFileType == SCH_IO_MGR::SCH_LEGACY )
{
// Don't reload the symbol libraries if we are just launching Eeschema from KiCad again.
@ -401,7 +390,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SCH_PLUGIN* plugin = SCH_IO_MGR::FindPlugin( schFileType );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin );
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Schematic" ), 1 );
pi->SetProgressReporter( &progressReporter );
bool failedLoad = false;
@ -769,7 +757,7 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
if( pluginType == SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN )
{
wxLogError( wxString::Format( "unexpected file extension: %s", fn.GetExt() ) );
wxLogError( _( "Unexpected file extension: '%s'." ), fn.GetExt() );
return;
}

View File

@ -556,7 +556,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// This is for python:
if( aFileSet.size() != 1 )
{
UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ );
UTF8 msg = StrPrintf( "Pcbnew:%s() takes a single filename", __func__ );
DisplayError( this, msg );
return false;
}
@ -575,7 +575,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( !lockFile )
{
wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName );
wxString msg = wxString::Format( _( "PCB '%s' is already open." ), fullFileName );
DisplayError( this, msg );
return false;
}
@ -610,9 +610,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// Get rid of any existing warnings about the old board
GetInfoBar()->Dismiss();
// Loading a complex project and build data can be time
// consuming, so display a busy cursor
wxBusyCursor dummy;
WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Creating PCB" )
: _( "Loading PCB" ), 1 );
// No save prompt (we already prompted above), and only reset to a new blank board if new
Clear_Pcb( false, !is_new );
@ -690,7 +689,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
props["page_width"] = xbuf;
props["page_height"] = ybuf;
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading PCB" ), 1 );
#if USE_INSTRUMENTATION
// measure the time to load a BOARD.
unsigned startTime = GetRunningMicroSecs();
@ -707,18 +705,17 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
{
if( ioe.Problem() != wxT( "CANCEL" ) )
{
wxString msg = wxString::Format( _( "Error loading board file:\n%s" ),
fullFileName );
DisplayErrorMessage( this, msg, ioe.What() );
DisplayErrorMessage( this, wxString::Format( _( "Error loading PCB '%s'." ),
fullFileName ),
ioe.What() );
}
failedLoad = true;
}
catch( const std::bad_alloc& )
{
wxString msg = wxString::Format( _( "Memory exhausted loading board file:\n%s" ), fullFileName );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( this, wxString::Format( _( "Memory exhausted loading PCB '%s'" ),
fullFileName ) );
failedLoad = true;
}
@ -824,11 +821,10 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
catch( const IO_ERROR& ioe )
{
wxLogError( wxString::Format( _( "Error occurred when saving footprint "
"'%s' to the project specific footprint "
"library: %s" ),
footprint->GetFPID().GetUniStringLibItemName(),
ioe.What() ) );
wxLogError( _( "Error saving footprint %s to project specific library." )
+ wxS( "\n%s" ),
footprint->GetFPID().GetUniStringLibItemName(),
ioe.What() );
}
}
@ -854,9 +850,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
catch( const IO_ERROR& ioe )
{
wxLogError( wxString::Format( _( "Error occurred saving the project specific "
"footprint library table: %s" ),
ioe.What() ) );
wxLogError( _( "Error saving project specific footprint library table." )
+ wxS( "\n%s" ),
ioe.What() );
}
// Update footprint LIB_IDs to point to the just imported library