Symbol editor: minor fixes to disable saving the legacy file format.
Fixes https://gitlab.com/kicad/code/kicad/issues/4093
This commit is contained in:
parent
6c8b937e1b
commit
c2d94358fc
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -696,7 +696,7 @@ bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString
|
|||
if( aOriginalFile.FileExists() )
|
||||
{
|
||||
wxFileName backupFileName( aOriginalFile );
|
||||
backupFileName.SetExt( "bck" );
|
||||
backupFileName.SetExt( aBackupExt );
|
||||
|
||||
if( backupFileName.FileExists() )
|
||||
wxRemoveFile( backupFileName.GetFullPath() );
|
||||
|
|
|
@ -272,18 +272,7 @@ bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
|
|||
{
|
||||
wxCHECK( LibraryExists( aLibrary ), true );
|
||||
|
||||
wxFileName fn( symTable()->GetFullURI( aLibrary ) );
|
||||
|
||||
// From hence forth, legacy symbol libraries are not writable.
|
||||
const SYMBOL_LIB_TABLE_ROW* row = dynamic_cast<const SYMBOL_LIB_TABLE_ROW*>(
|
||||
symTable()->FindRowByURI( fn.GetFullPath() ) );
|
||||
SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
|
||||
|
||||
if( row )
|
||||
fileType = SCH_IO_MGR::EnumFromStr( row->GetType() );
|
||||
|
||||
return ( fileType == SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY ) ||
|
||||
( fn.FileExists() && !fn.IsFileWritable() ) || !fn.IsDirWritable();
|
||||
return !symTable()->IsSymbolLibWritable( aLibrary );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -841,7 +841,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
|
|||
}
|
||||
|
||||
// Verify the user has write privileges before attempting to save the library file.
|
||||
if( !IsWritable( fn ) )
|
||||
if( m_libMgr->IsLibraryReadOnly( aLibrary ) )
|
||||
return false;
|
||||
|
||||
ClearMsgPanel();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -45,7 +45,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
const wxString& partName = libId.GetLibItemName();
|
||||
bool readOnly = libName.IsEmpty();
|
||||
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
||||
|
||||
if( partName.IsEmpty() )
|
||||
return ( !readOnly && m_libMgr->IsLibraryModified( libName ) );
|
||||
|
|
|
@ -4537,7 +4537,8 @@ bool SCH_LEGACY_PLUGIN::CheckHeader( const wxString& aFileName )
|
|||
|
||||
bool SCH_LEGACY_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
return wxFileName::IsFileWritable( aLibraryPath );
|
||||
// Writing legacy symbol libraries is deprecated.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2175,7 +2175,9 @@ bool SCH_SEXPR_PLUGIN::CheckHeader( const wxString& aFileName )
|
|||
|
||||
bool SCH_SEXPR_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
return wxFileName::IsFileWritable( aLibraryPath );
|
||||
wxFileName fn( aLibraryPath );
|
||||
|
||||
return ( fn.FileExists() && fn.IsFileWritable() ) || fn.IsDirWritable();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue