From 1fd3f4e37553e57366b3eab0ce75cfe1fd720ed0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 23 Sep 2023 12:24:42 +0100 Subject: [PATCH] Handle read-only libraries when saving symbol from canvas. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15519 --- eeschema/symbol_editor/symbol_editor.cpp | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 7770dab7b3..5c7d72086e 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -119,14 +119,20 @@ bool SYMBOL_EDIT_FRAME::saveCurrentSymbol() } else { - LIB_ID libId = GetCurSymbol()->GetLibId(); - const wxString& libName = libId.GetLibNickname(); - const wxString& symbolName = libId.GetLibItemName(); + const wxString& libName = GetCurSymbol()->GetLibId().GetLibNickname(); - if( m_libMgr->FlushSymbol( symbolName, libName ) ) + if( m_libMgr->IsLibraryReadOnly( libName ) ) { - m_libMgr->ClearSymbolModified( symbolName, libName ); - return true; + wxString msg = wxString::Format( _( "Symbol library '%s' is not writable." ), + libName ); + wxString msg2 = _( "You must save to a different location." ); + + if( OKOrCancelDialog( this, _( "Warning" ), msg, msg2 ) == wxID_OK ) + return saveLibrary( libName, true ); + } + else + { + return saveLibrary( libName, false ); } } } @@ -1200,12 +1206,7 @@ bool SYMBOL_EDIT_FRAME::saveAllLibraries( bool aRequireConfirmation ) { // If saving under existing name fails then do a Save As..., and if that // fails then cancel close action. - if( !m_libMgr->IsLibraryReadOnly( libNickname ) ) - { - if( saveLibrary( libNickname, false ) ) - continue; - } - else + if( m_libMgr->IsLibraryReadOnly( libNickname ) ) { msg.Printf( _( "Symbol library '%s' is not writable." ), libNickname ); msg2 = _( "You must save to a different location." ); @@ -1231,6 +1232,10 @@ bool SYMBOL_EDIT_FRAME::saveAllLibraries( bool aRequireConfirmation ) continue; } } + else if( saveLibrary( libNickname, false ) ) + { + continue; + } if( !saveLibrary( libNickname, true ) ) retv = false;