Refresh lib trees after editing library tables.

Also make sure that we grab the library item descriptions from their
source rather than just the cached tree copy.

Fixes https://gitlab.com/kicad/code/kicad/issues/7875
This commit is contained in:
Jeff Young 2021-03-17 14:53:27 +00:00
parent fee3c41c40
commit 36259b1f6b
8 changed files with 49 additions and 12 deletions

View File

@ -982,7 +982,7 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
currentLib = symbolEditor->GetCurLib();
// This prevents an ugly crash on OSX (https://bugs.launchpad.net/kicad/+bug/1765286)
symbolEditor->FreezeSearchTree();
symbolEditor->FreezeLibraryTree();
if( symbolEditor->HasLibModifications() )
{
@ -992,10 +992,10 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
switch( UnsavedChangesDialog( aParent, msg ) )
{
case wxID_YES: symbolEditor->SaveAll(); break;
case wxID_NO: symbolEditor->RevertAll(); break;
case wxID_YES: symbolEditor->SaveAll(); break;
case wxID_NO: symbolEditor->RevertAll(); break;
default:
case wxID_CANCEL: symbolEditor->ThawSearchTree(); return;
case wxID_CANCEL: symbolEditor->ThawLibraryTree(); return;
}
}
}
@ -1009,7 +1009,7 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
if( dlg.ShowModal() == wxID_CANCEL )
{
if( symbolEditor )
symbolEditor->ThawSearchTree();
symbolEditor->ThawLibraryTree();
return;
}
@ -1053,7 +1053,8 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
}
symbolEditor->SyncLibraries( true );
symbolEditor->ThawSearchTree();
symbolEditor->ThawLibraryTree();
symbolEditor->RefreshLibraryTree();
}
if( symbolViewer )

View File

@ -569,14 +569,14 @@ bool SYMBOL_EDIT_FRAME::IsSearchTreeShown()
}
void SYMBOL_EDIT_FRAME::FreezeSearchTree()
void SYMBOL_EDIT_FRAME::FreezeLibraryTree()
{
m_treePane->Freeze();
m_libMgr->GetAdapter()->Freeze();
}
void SYMBOL_EDIT_FRAME::ThawSearchTree()
void SYMBOL_EDIT_FRAME::ThawLibraryTree()
{
m_libMgr->GetAdapter()->Thaw();
m_treePane->Thaw();
@ -955,6 +955,12 @@ void SYMBOL_EDIT_FRAME::RegenerateLibraryTree()
}
void SYMBOL_EDIT_FRAME::RefreshLibraryTree()
{
m_treePane->GetLibTree()->RefreshLibTree();
}
SYMBOL_LIB_TABLE* SYMBOL_EDIT_FRAME::selectSymLibTable( bool aOptional )
{
// If no project is loaded, always work with the global table

View File

@ -173,8 +173,8 @@ public:
void OnToggleSearchTree( wxCommandEvent& event );
bool IsSearchTreeShown();
void FreezeSearchTree();
void ThawSearchTree();
void FreezeLibraryTree();
void ThawLibraryTree();
void OnUpdatePartNumber( wxUpdateUIEvent& event );
@ -301,6 +301,11 @@ public:
*/
void RegenerateLibraryTree();
/**
* Redisplay the library tree. Used after changing modified states, descriptions, etc.
*/
void RefreshLibraryTree();
/**
* Allow the symbol editor to install its preferences panel into the preferences dialog.
*/

View File

@ -1072,9 +1072,9 @@ bool SYMBOL_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
if( resyncLibTree )
{
FreezeSearchTree();
FreezeLibraryTree();
SyncLibraries( true, forceRefresh );
ThawSearchTree();
ThawLibraryTree();
}
}

View File

@ -237,7 +237,17 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataVie
case 1:
if( m_frame->GetCurPart() && m_frame->GetCurPart()->GetLibId() == node->m_LibId )
{
node->m_Desc = m_frame->GetCurPart()->GetDescription();
}
else if( node->m_Type == LIB_TREE_NODE::LIB )
{
SYMBOL_LIBRARY_MANAGER& libMgr = m_frame->GetLibManager();
SYMBOL_LIB_TABLE_ROW* lib = libMgr.GetLibrary( node->m_LibId.GetLibNickname() );
if( lib )
node->m_Desc = lib->GetDescr();
}
aVariant = node->m_Desc;

View File

@ -1083,7 +1083,10 @@ void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller )
auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
if( editor )
{
editor->SyncLibraryTree( true );
editor->RefreshLibraryTree();
}
auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );

View File

@ -300,6 +300,9 @@ public:
*/
void RegenerateLibraryTree();
/**
* Redisplay the library tree. Used after changing modified states, descriptions, etc.
*/
void RefreshLibraryTree();
///< Reload displayed items and sets view.

View File

@ -192,7 +192,16 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
case 1:
if( node->m_LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() )
{
node->m_Desc = m_frame->GetBoard()->GetFirstFootprint()->GetDescription();
}
else if( node->m_Type == LIB_TREE_NODE::LIB )
{
const FP_LIB_TABLE_ROW* lib = GFootprintTable.FindRow( node->m_LibId.GetLibNickname() );
if( lib )
node->m_Desc = lib->GetDescr();
}
aVariant = node->m_Desc;
break;