mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-14 13:09:35 +00:00
Use lock when clearing and loading libTables.
Also make sure it's re-indexed after loading.
This commit is contained in:
parent
e2bd76bdce
commit
0f099ac65e
common
eeschema
include
pcbnew
qa/tests/common
@ -607,7 +607,6 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable )
|
||||
}
|
||||
}
|
||||
|
||||
aTable.Clear();
|
||||
aTable.Load( fn.GetFullPath() );
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
@ -128,7 +128,7 @@ LIB_TABLE::~LIB_TABLE()
|
||||
}
|
||||
|
||||
|
||||
void LIB_TABLE::Clear()
|
||||
void LIB_TABLE::clear()
|
||||
{
|
||||
m_rows.clear();
|
||||
m_rowsMap.clear();
|
||||
@ -406,6 +406,7 @@ void LIB_TABLE::TransferRows( LIB_TABLE_ROWS& aRowsList )
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> lock( m_mutex );
|
||||
|
||||
clear();
|
||||
m_rows.transfer( m_rows.end(), aRowsList.begin(), aRowsList.end(), aRowsList );
|
||||
|
||||
reindex();
|
||||
@ -451,6 +452,9 @@ bool LIB_TABLE::migrate()
|
||||
|
||||
void LIB_TABLE::Load( const wxString& aFileName )
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock( m_mutex );
|
||||
clear();
|
||||
|
||||
// It's OK if footprint library tables are missing.
|
||||
if( wxFileName::IsFileReadable( aFileName ) )
|
||||
{
|
||||
@ -461,6 +465,8 @@ void LIB_TABLE::Load( const wxString& aFileName )
|
||||
|
||||
if( m_version != 7 && migrate() && wxFileName::IsFileWritable( aFileName ) )
|
||||
Save( aFileName );
|
||||
|
||||
reindex();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1014,16 +1014,12 @@ bool PANEL_SYM_LIB_TABLE::TransferDataFromWindow()
|
||||
if( *global_model() != *m_globalTable )
|
||||
{
|
||||
m_parent->m_GlobalTableChanged = true;
|
||||
|
||||
m_globalTable->Clear();
|
||||
m_globalTable->TransferRows( global_model()->m_rows );
|
||||
}
|
||||
|
||||
if( project_model() && *project_model() != *m_projectTable )
|
||||
{
|
||||
m_parent->m_ProjectTableChanged = true;
|
||||
|
||||
m_projectTable->Clear();
|
||||
m_projectTable->TransferRows( project_model()->m_rows );
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,6 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable )
|
||||
}
|
||||
}
|
||||
|
||||
aTable.Clear();
|
||||
aTable.Load( fn.GetFullPath() );
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
@ -334,9 +334,6 @@ public:
|
||||
|
||||
virtual ~LIB_TABLE();
|
||||
|
||||
/// Delete all rows.
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* Compares this table against another.
|
||||
*
|
||||
@ -530,6 +527,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Do not make this public. It MUST be called with a lock already in place.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Return a #LIB_TABLE_ROW if \a aNickname is found in this table or in any chained
|
||||
* fallBack table fragment, else NULL.
|
||||
|
@ -1128,16 +1128,12 @@ bool PANEL_FP_LIB_TABLE::TransferDataFromWindow()
|
||||
if( *global_model() != *m_globalTable )
|
||||
{
|
||||
m_parent->m_GlobalTableChanged = true;
|
||||
|
||||
m_globalTable->Clear();
|
||||
m_globalTable->TransferRows( global_model()->m_rows );
|
||||
}
|
||||
|
||||
if( project_model() && *project_model() != *m_projectTable )
|
||||
{
|
||||
m_parent->m_ProjectTableChanged = true;
|
||||
|
||||
m_projectTable->Clear();
|
||||
m_projectTable->TransferRows( project_model()->m_rows );
|
||||
}
|
||||
|
||||
|
@ -556,10 +556,9 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
|
||||
|
||||
// Load the global fp-lib-table otherwise we can't check the libs parity
|
||||
wxFileName fn_flp = FP_LIB_TABLE::GetGlobalTableFileName();
|
||||
if( fn_flp.FileExists() ) {
|
||||
GFootprintTable.Clear();
|
||||
|
||||
if( fn_flp.FileExists() )
|
||||
GFootprintTable.Load( fn_flp.GetFullPath() );
|
||||
}
|
||||
|
||||
wxString drcRulesPath = prj->AbsolutePath( fn.GetFullName() );
|
||||
|
||||
|
@ -234,19 +234,6 @@ BOOST_AUTO_TEST_CASE( EmptyWithFallback )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check table clearing function
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE( Clear )
|
||||
{
|
||||
m_mainTableNoFb.Clear();
|
||||
|
||||
// Tables start out empty
|
||||
BOOST_CHECK_EQUAL( m_mainTableNoFb.GetCount(), 0 );
|
||||
BOOST_CHECK_EQUAL( true, m_mainTableNoFb.IsEmpty() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check table equality function
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user