diff --git a/common/design_block_lib_table.cpp b/common/design_block_lib_table.cpp index 69ab52f033..d46b30db07 100644 --- a/common/design_block_lib_table.cpp +++ b/common/design_block_lib_table.cpp @@ -672,6 +672,18 @@ bool DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable ) } +DESIGN_BLOCK_LIB_TABLE& DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() +{ + return GDesignBlockTable; +} + + +DESIGN_BLOCK_LIST_IMPL& DESIGN_BLOCK_LIB_TABLE::GetGlobalList() +{ + return GDesignBlockList; +} + + wxString DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName() { wxFileName fn; diff --git a/common/dialogs/panel_design_block_lib_table.cpp b/common/dialogs/panel_design_block_lib_table.cpp index 600cc07a81..3dfe6eec8c 100644 --- a/common/dialogs/panel_design_block_lib_table.cpp +++ b/common/dialogs/panel_design_block_lib_table.cpp @@ -1157,7 +1157,7 @@ size_t PANEL_DESIGN_BLOCK_LIB_TABLE::m_pageNdx = 0; void InvokeEditDesignBlockLibTable( KIWAY* aKiway, wxWindow *aParent ) { - DESIGN_BLOCK_LIB_TABLE* globalTable = &GDesignBlockTable; + DESIGN_BLOCK_LIB_TABLE* globalTable = &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable(); wxString globalTablePath = DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName(); DESIGN_BLOCK_LIB_TABLE* projectTable = aKiway->Prj().DesignBlockLibs(); wxString projectTablePath = aKiway->Prj().DesignBlockLibTblName(); diff --git a/common/project.cpp b/common/project.cpp index 6bbd3098df..255ac7d4bb 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -430,7 +430,7 @@ DESIGN_BLOCK_LIB_TABLE* PROJECT::DesignBlockLibs() { try { - tbl = new DESIGN_BLOCK_LIB_TABLE( &GDesignBlockTable ); + tbl = new DESIGN_BLOCK_LIB_TABLE( &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() ); tbl->Load( DesignBlockLibTblName() ); SetElem( ELEM::DESIGN_BLOCK_LIB_TABLE, tbl ); diff --git a/eeschema/design_block_tree_model_adapter.cpp b/eeschema/design_block_tree_model_adapter.cpp index 1a8763f76f..ccb27013c8 100644 --- a/eeschema/design_block_tree_model_adapter.cpp +++ b/eeschema/design_block_tree_model_adapter.cpp @@ -93,9 +93,9 @@ DESIGN_BLOCK_TREE_MODEL_ADAPTER::getDesignBlocks( EDA_BASE_FRAME* aParent, { std::vector libList; + auto fullListStart = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetList().begin(); + auto fullListEnd = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetList().end(); - auto fullListStart = GDesignBlockList.GetList().begin(); - auto fullListEnd = GDesignBlockList.GetList().end(); std::unique_ptr dummy = std::make_unique( aLibName, wxEmptyString ); diff --git a/eeschema/design_block_utils.cpp b/eeschema/design_block_utils.cpp index c08c8af5cc..a834a8f159 100644 --- a/eeschema/design_block_utils.cpp +++ b/eeschema/design_block_utils.cpp @@ -44,7 +44,7 @@ DESIGN_BLOCK_LIB_TABLE* SCH_EDIT_FRAME::selectDesignBlockLibTable( bool aOptiona // If no project is loaded, always work with the global table if( Prj().IsNullProject() ) { - DESIGN_BLOCK_LIB_TABLE* ret = &GDesignBlockTable; + DESIGN_BLOCK_LIB_TABLE* ret = &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable(); if( aOptional ) { @@ -76,7 +76,7 @@ DESIGN_BLOCK_LIB_TABLE* SCH_EDIT_FRAME::selectDesignBlockLibTable( bool aOptiona switch( dlg.GetSelection() ) { - case 0: return &GDesignBlockTable; + case 0: return &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable(); case 1: return Prj().DesignBlockLibs(); default: return nullptr; } @@ -99,7 +99,7 @@ wxString SCH_EDIT_FRAME::createNewDesignBlockLibrary( const wxString& aL wxFileName fn; bool doAdd = false; - bool isGlobal = ( aTable == &GDesignBlockTable ); + bool isGlobal = ( aTable == &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() ); wxString initialPath = aProposedName; if( initialPath.IsEmpty() ) @@ -196,7 +196,7 @@ bool SCH_EDIT_FRAME::AddDesignBlockLibrary( const wxString& aFilename, if( aTable == nullptr ) return wxEmptyString; - bool isGlobal = ( aTable == &GDesignBlockTable ); + bool isGlobal = ( aTable == &DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() ); wxFileName fn( aFilename ); @@ -244,7 +244,8 @@ bool SCH_EDIT_FRAME::AddDesignBlockLibrary( const wxString& aFilename, aTable->InsertRow( row ); if( isGlobal ) - GDesignBlockTable.Save( DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName() ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable().Save( + DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName() ); else Prj().DesignBlockLibs()->Save( Prj().DesignBlockLibTblName() ); } diff --git a/eeschema/widgets/panel_design_block_chooser.cpp b/eeschema/widgets/panel_design_block_chooser.cpp index 941fe8ecd1..325a1644b1 100644 --- a/eeschema/widgets/panel_design_block_chooser.cpp +++ b/eeschema/widgets/panel_design_block_chooser.cpp @@ -69,7 +69,7 @@ PANEL_DESIGN_BLOCK_CHOOSER::PANEL_DESIGN_BLOCK_CHOOSER( SCH_EDIT_FRAME* aFrame, // Load design block files: WX_PROGRESS_REPORTER* progressReporter = new WX_PROGRESS_REPORTER( aParent, _( "Loading Design Block Libraries" ), 3 ); - GDesignBlockList.ReadDesignBlockFiles( libs, nullptr, progressReporter ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadDesignBlockFiles( libs, nullptr, progressReporter ); // Force immediate deletion of the WX_PROGRESS_REPORTER. Do not use Destroy(), or use // Destroy() followed by wxSafeYield() because on Windows, APP_PROGRESS_DIALOG and @@ -78,7 +78,7 @@ PANEL_DESIGN_BLOCK_CHOOSER::PANEL_DESIGN_BLOCK_CHOOSER( SCH_EDIT_FRAME* aFrame, // WX_PROGRESS_REPORTER results in incorrect modal or quasi modal behavior. delete progressReporter; - if( GDesignBlockList.GetErrorCount() ) + if( DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetErrorCount() ) displayErrors( aFrame ); m_adapter = DESIGN_BLOCK_TREE_MODEL_ADAPTER::Create( m_frame, libs ); @@ -260,12 +260,13 @@ void PANEL_DESIGN_BLOCK_CHOOSER::RefreshLibs( bool aProgress ) if( aProgress ) { WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Design Block Libraries" ), 2 ); - GDesignBlockList.ReadDesignBlockFiles( fpTable, nullptr, &progressReporter ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadDesignBlockFiles( fpTable, nullptr, + &progressReporter ); progressReporter.Show( false ); } else { - GDesignBlockList.ReadDesignBlockFiles( fpTable, nullptr, nullptr ); + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadDesignBlockFiles( fpTable, nullptr, nullptr ); } rebuildHistoryNode(); @@ -392,8 +393,8 @@ void PANEL_DESIGN_BLOCK_CHOOSER::rebuildHistoryNode() for( const LIB_ID& lib : m_historyList ) { - LIB_TREE_ITEM* fp_info = - GDesignBlockList.GetDesignBlockInfo( lib.GetLibNickname(), lib.GetLibItemName() ); + LIB_TREE_ITEM* fp_info = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetDesignBlockInfo( + lib.GetLibNickname(), lib.GetLibItemName() ); // this can be null, for example, if the design block has been deleted from a library. if( fp_info != nullptr ) @@ -416,7 +417,7 @@ void PANEL_DESIGN_BLOCK_CHOOSER::displayErrors( wxTopLevelWindow* aWindow ) wxString msg; - while( std::unique_ptr error = GDesignBlockList.PopError() ) + while( std::unique_ptr error = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().PopError() ) { wxString tmp = EscapeHTML( error->Problem() ); diff --git a/include/design_block_lib_table.h b/include/design_block_lib_table.h index 60c6868988..91fa71bcb4 100644 --- a/include/design_block_lib_table.h +++ b/include/design_block_lib_table.h @@ -266,6 +266,10 @@ public: */ static bool LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable ); + static DESIGN_BLOCK_LIB_TABLE& GetGlobalLibTable(); + + static DESIGN_BLOCK_LIST_IMPL& GetGlobalList(); + /** * @return the platform specific global design block library path and file name. */ @@ -285,7 +289,4 @@ private: friend class DESIGN_BLOCK_LIB_TABLE_GRID; }; -KICOMMON_API extern DESIGN_BLOCK_LIB_TABLE GDesignBlockTable; -KICOMMON_API extern DESIGN_BLOCK_LIST_IMPL GDesignBlockList; - #endif // DESIGN_BLOCK_LIB_TABLE_H_ diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 631cfcccf3..05f5936a7b 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -357,7 +357,7 @@ bool PGM_KICAD::OnPgmInit() try { - DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable( GDesignBlockTable ); + DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE::GetGlobalLibTable() ); } catch( const IO_ERROR& ioe ) { @@ -372,9 +372,9 @@ bool PGM_KICAD::OnPgmInit() DisplayErrorMessage( nullptr, msg, ioe.What() ); } - if( managerFrame->IsProjectActive() && GDesignBlockList.GetCount() == 0 ) - GDesignBlockList.ReadCacheFromFile( Prj().GetProjectPath() - + wxT( "design-block-info-cache" ) ); + if( managerFrame->IsProjectActive() && DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetCount() == 0 ) + DESIGN_BLOCK_LIB_TABLE::GetGlobalList().ReadCacheFromFile( + Prj().GetProjectPath() + wxT( "design-block-info-cache" ) ); frame->Show( true ); frame->Raise();