Eeschema: don't stat files when updating title bar text.
The tests for file existence and write status perform two file stats which cause performance issues on slow network shares. Now the file state is determined at load time and stored in the SCH_SCREEN object so file access is no longer required. Fixes https://gitlab.com/kicad/code/kicad/-/issues/9343
This commit is contained in:
parent
fb8ee1a9d3
commit
c61af21da8
|
@ -1231,16 +1231,20 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM*
|
|||
|
||||
void SCH_EDIT_FRAME::UpdateTitle()
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
|
||||
wxCHECK( screen, /* void */ );
|
||||
|
||||
wxString title;
|
||||
|
||||
if( !GetScreen()->GetFileName().IsEmpty() )
|
||||
if( !screen->GetFileName().IsEmpty() )
|
||||
{
|
||||
wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
|
||||
wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
|
||||
bool readOnly = false;
|
||||
bool unsaved = false;
|
||||
|
||||
if( fn.IsOk() && fn.FileExists() )
|
||||
readOnly = !fn.IsFileWritable();
|
||||
if( fn.IsOk() && screen->FileExists() )
|
||||
readOnly = screen->IsReadOnly();
|
||||
else
|
||||
unsaved = true;
|
||||
|
||||
|
|
|
@ -519,6 +519,9 @@ void SCH_SEXPR_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
|||
m_error += ioe.What();
|
||||
}
|
||||
|
||||
aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
|
||||
aSheet->GetScreen()->SetFileExists( true );
|
||||
|
||||
// This was moved out of the try{} block so that any sheets definitionsthat
|
||||
// the plugin fully parsed before the exception was raised will be loaded.
|
||||
for( SCH_ITEM* aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
|
||||
|
@ -594,6 +597,8 @@ void SCH_SEXPR_PLUGIN::Save( const wxString& aFileName, SCH_SHEET* aSheet, SCHEM
|
|||
m_out = &formatter; // no ownership
|
||||
|
||||
Format( aSheet );
|
||||
|
||||
aSheet->GetScreen()->SetFileExists( true );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -744,6 +744,9 @@ void SCH_LEGACY_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
|||
m_error += ioe.What();
|
||||
}
|
||||
|
||||
aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
|
||||
aSheet->GetScreen()->SetFileExists( true );
|
||||
|
||||
for( auto aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
|
||||
{
|
||||
wxCHECK2( aItem->Type() == SCH_SHEET_T, continue );
|
||||
|
@ -1864,6 +1867,7 @@ std::shared_ptr<BUS_ALIAS> SCH_LEGACY_PLUGIN::loadBusAlias( LINE_READER& aReader
|
|||
{
|
||||
buf.clear();
|
||||
parseUnquotedString( buf, aReader, line, &line, true );
|
||||
|
||||
if( buf.Len() > 0 )
|
||||
{
|
||||
busAlias->AddMember( buf );
|
||||
|
@ -1895,6 +1899,8 @@ void SCH_LEGACY_PLUGIN::Save( const wxString& aFileName, SCH_SHEET* aSheet, SCHE
|
|||
m_out = &formatter; // no ownership
|
||||
|
||||
Format( aSheet );
|
||||
|
||||
aSheet->GetScreen()->SetFileExists( true );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,9 @@
|
|||
SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
|
||||
BASE_SCREEN( aParent, SCH_SCREEN_T ),
|
||||
m_fileFormatVersionAtLoad( 0 ),
|
||||
m_paper( wxT( "A4" ) )
|
||||
m_paper( wxT( "A4" ) ),
|
||||
m_isReadOnly( false ),
|
||||
m_fileExists( false )
|
||||
{
|
||||
m_modification_sync = 0;
|
||||
m_refCount = 0;
|
||||
|
|
|
@ -144,6 +144,12 @@ public:
|
|||
|
||||
const wxString& GetFileName() const { return m_fileName; }
|
||||
|
||||
void SetFileReadOnly( bool aIsReadOnly ) { m_isReadOnly = aIsReadOnly; }
|
||||
bool IsReadOnly() const { return m_isReadOnly; }
|
||||
|
||||
void SetFileExists( bool aFileExists ) { m_fileExists = aFileExists; }
|
||||
bool FileExists() const { return m_fileExists; }
|
||||
|
||||
const wxPoint& GetAuxOrigin() const { return m_aux_origin; }
|
||||
void SetAuxOrigin( const wxPoint& aPosition ) { m_aux_origin = aPosition; }
|
||||
|
||||
|
@ -512,6 +518,11 @@ private:
|
|||
bool m_zoomInitialized; // Set to true once the zoom value is initialized with
|
||||
// `InitZoom()`.
|
||||
|
||||
bool m_isReadOnly; ///< Read only status of the screen file.
|
||||
|
||||
///< Flag to indicate the file associated with this screen has been created.
|
||||
bool m_fileExists;
|
||||
|
||||
/// List of bus aliases stored in this screen.
|
||||
std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases;
|
||||
|
||||
|
|
Loading…
Reference in New Issue