Clear selection before importing schematic.
Also moves some error messages to use consistent terminology. Fixes https://gitlab.com/kicad/code/kicad/issues/8421
This commit is contained in:
parent
9ebabb222c
commit
ed0e0a00c0
|
@ -415,8 +415,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Error loading schematic file \"%s\"" ),
|
msg.Printf( _( "Error loading schematic '%s'." ), fullFileName);
|
||||||
fullFileName);
|
|
||||||
DisplayErrorMessage( this, msg, ioe.What() );
|
DisplayErrorMessage( this, msg, ioe.What() );
|
||||||
|
|
||||||
failedLoad = true;
|
failedLoad = true;
|
||||||
|
@ -436,7 +435,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
CreateScreens();
|
CreateScreens();
|
||||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||||
|
|
||||||
msg.Printf( _( "Failed to load \"%s\"" ), fullFileName );
|
msg.Printf( _( "Failed to load '%s'." ), fullFileName );
|
||||||
SetMsgPanel( wxEmptyString, msg );
|
SetMsgPanel( wxEmptyString, msg );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -628,7 +627,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
{
|
{
|
||||||
m_infoBar->RemoveAllButtons();
|
m_infoBar->RemoveAllButtons();
|
||||||
m_infoBar->AddCloseButton();
|
m_infoBar->AddCloseButton();
|
||||||
m_infoBar->ShowMessage( _( "Schematic file is read only." ), wxICON_WARNING );
|
m_infoBar->ShowMessage( _( "Schematic is read only." ), wxICON_WARNING );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
|
@ -713,7 +712,7 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
|
||||||
wxString fileFilters;
|
wxString fileFilters;
|
||||||
wxString allWildcards;
|
wxString allWildcards;
|
||||||
|
|
||||||
for( auto& loader : loaders )
|
for( std::pair<const wxString, const SCH_IO_MGR::SCH_FILE_T>& loader : loaders )
|
||||||
{
|
{
|
||||||
if( !fileFilters.IsEmpty() )
|
if( !fileFilters.IsEmpty() )
|
||||||
fileFilters += wxChar( '|' );
|
fileFilters += wxChar( '|' );
|
||||||
|
@ -751,7 +750,7 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
|
SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
|
||||||
|
|
||||||
for( auto& loader : loaders )
|
for( std::pair<const wxString, const SCH_IO_MGR::SCH_FILE_T>& loader : loaders )
|
||||||
{
|
{
|
||||||
if( fn.GetExt().CmpNoCase( SCH_IO_MGR::GetFileExtension( loader.second ) ) == 0 )
|
if( fn.GetExt().CmpNoCase( SCH_IO_MGR::GetFileExtension( loader.second ) ) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -766,6 +765,8 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_toolManager->GetTool<EE_SELECTION_TOOL>()->ClearSelection();
|
||||||
|
|
||||||
importFile( dlg.GetPath(), pluginType );
|
importFile( dlg.GetPath(), pluginType );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,9 +802,11 @@ bool SCH_EDIT_FRAME::SaveProject()
|
||||||
if( newFileName.GetExt().IsEmpty() )
|
if( newFileName.GetExt().IsEmpty() )
|
||||||
newFileName.SetExt( KiCadSchematicFileExtension );
|
newFileName.SetExt( KiCadSchematicFileExtension );
|
||||||
|
|
||||||
if( !newFileName.DirExists() && !newFileName.Mkdir() )
|
if( ( !newFileName.DirExists() && !newFileName.Mkdir() ) || !newFileName.IsDirWritable() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Cannot create folder \"%s\"." ), newFileName.GetPath() );
|
msg.Printf( _( "Folder '%s' could not be created.\n\n"
|
||||||
|
"Make sure you have write permissions and try again." ),
|
||||||
|
newFileName.GetPath() );
|
||||||
|
|
||||||
wxMessageDialog dlgBadPath( this, msg, _( "Error" ),
|
wxMessageDialog dlgBadPath( this, msg, _( "Error" ),
|
||||||
wxOK | wxICON_EXCLAMATION | wxCENTER );
|
wxOK | wxICON_EXCLAMATION | wxCENTER );
|
||||||
|
@ -812,18 +815,6 @@ bool SCH_EDIT_FRAME::SaveProject()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !newFileName.IsDirWritable() )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
|
|
||||||
newFileName.GetPath() );
|
|
||||||
|
|
||||||
wxMessageDialog dlgBadPerms( this, msg, _( "Error" ),
|
|
||||||
wxOK | wxICON_EXCLAMATION | wxCENTER );
|
|
||||||
|
|
||||||
dlgBadPerms.ShowModal();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Schematic().Root().SetFileName( newFileName.GetFullName() );
|
Schematic().Root().SetFileName( newFileName.GetFullName() );
|
||||||
Schematic().RootScreen()->SetFileName( newFileName.GetFullPath() );
|
Schematic().RootScreen()->SetFileName( newFileName.GetFullPath() );
|
||||||
|
|
||||||
|
@ -864,12 +855,15 @@ bool SCH_EDIT_FRAME::SaveProject()
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogTrace( tracePathsAndFiles,
|
wxLogTrace( tracePathsAndFiles,
|
||||||
wxT( "Changing schematic file name path from '%s' to '%s'." ),
|
wxT( "Moving schematic from '%s' to '%s'." ),
|
||||||
screen->GetFileName(), tmp.GetFullPath() );
|
screen->GetFileName(),
|
||||||
|
tmp.GetFullPath() );
|
||||||
|
|
||||||
if( !tmp.DirExists() && !tmp.Mkdir() )
|
if( !tmp.DirExists() && !tmp.Mkdir() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Cannot create folder \"%s\"." ), newFileName.GetPath() );
|
msg.Printf( _( "Folder '%s' could not be created.\n\n"
|
||||||
|
"Make sure you have write permissions and try again." ),
|
||||||
|
newFileName.GetPath() );
|
||||||
|
|
||||||
wxMessageDialog dlgBadFilePath( this, msg, _( "Error" ),
|
wxMessageDialog dlgBadFilePath( this, msg, _( "Error" ),
|
||||||
wxOK | wxICON_EXCLAMATION | wxCENTER );
|
wxOK | wxICON_EXCLAMATION | wxCENTER );
|
||||||
|
@ -1109,8 +1103,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||||
|
|
||||||
if( !LockFile( aFileName ) )
|
if( !LockFile( aFileName ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Schematic file \"%s\" is already open." ),
|
wxString msg = wxString::Format( _( "Schematic '%s' is already open." ), aFileName );
|
||||||
aFileName );
|
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1182,11 +1175,10 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||||
CreateScreens();
|
CreateScreens();
|
||||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||||
|
|
||||||
wxString msg;
|
wxString msg = wxString::Format( _( "Error loading schematic '%s'." ), aFileName );
|
||||||
msg.Printf( _( "Error loading schematic \"%s\".\n%s" ), aFileName, ioe.What() );
|
DisplayErrorMessage( this, msg, ioe.What() );
|
||||||
DisplayError( this, msg );
|
|
||||||
|
|
||||||
msg.Printf( _( "Failed to load \"%s\"" ), aFileName );
|
msg.Printf( _( "Failed to load '%s'." ), aFileName );
|
||||||
SetMsgPanel( wxEmptyString, msg );
|
SetMsgPanel( wxEmptyString, msg );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -161,7 +161,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
|
||||||
msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFilename );
|
msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFilename );
|
||||||
DisplayErrorMessage( this, msg, ioe.What() );
|
DisplayErrorMessage( this, msg, ioe.What() );
|
||||||
|
|
||||||
msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFilename );
|
msg.Printf( _( "Failed to load '%s'." ), fullFilename );
|
||||||
SetMsgPanel( wxEmptyString, msg );
|
SetMsgPanel( wxEmptyString, msg );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue