Fix override lock behavior

We don't need to lock in import because we are creating a new file.  We
should, however, show the locking user/machine when opening in schematic
editor and take over the lock if they want to proceed.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9347
This commit is contained in:
Seth Hillbrand 2023-05-30 11:00:08 -07:00
parent 15db42d9c8
commit 5370fdc718
1 changed files with 3 additions and 14 deletions

View File

@ -102,12 +102,13 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( !LockFile( fullFileName ) )
{
msg.Printf( _( "Schematic '%s' is already open." ), wx_filename.GetFullName() );
msg.Printf( _( "Schematic '%s' is already open by '%s' at '%s'." ), fullFileName,
m_file_checker->GetUsername(), m_file_checker->GetHostname() );
if( !OverrideLock( this, msg ) )
return false;
m_file_checker->OverrideLock( false );
m_file_checker->OverrideLock();
}
if( !AskToSaveChanges() )
@ -1225,18 +1226,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
wxCHECK_MSG( filename.IsAbsolute(), false,
wxT( "Import schematic: path is not absolute!" ) );
if( !LockFile( aFileName ) )
{
wxString msg;
msg.Printf( _( "Schematic '%s' is already open by '%s' at '%s'." ), aFileName,
m_file_checker->GetUsername(), m_file_checker->GetHostname() );
if( !OverrideLock( this, msg ) )
return false;
m_file_checker->OverrideLock();
}
try
{
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( fileType ) );