Prevent a crash due to the 3d preview dummy board stealing setting ownership

This commit is contained in:
Marek Roszko 2022-09-25 23:04:13 -04:00
parent c50b4fb04f
commit 707a598e5d
3 changed files with 5 additions and 4 deletions

View File

@ -54,7 +54,7 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_userUnits = aFrame->GetUserUnits();
m_dummyBoard = new BOARD();
m_dummyBoard->SetProject( &aFrame->Prj() );
m_dummyBoard->SetProject( &aFrame->Prj(), true );
// This board will only be used to hold a footprint for viewing
m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );

View File

@ -158,14 +158,14 @@ void BOARD::BuildConnectivity( PROGRESS_REPORTER* aReporter )
}
void BOARD::SetProject( PROJECT* aProject )
void BOARD::SetProject( PROJECT* aProject, bool aReferenceOnly )
{
if( m_project )
ClearProject();
m_project = aProject;
if( aProject )
if( aProject && !aReferenceOnly )
{
PROJECT_FILE& project = aProject->GetProjectFile();

View File

@ -445,8 +445,9 @@ public:
* Should be called immediately after loading board in order for everything to work.
*
* @param aProject is a loaded project to link to.
* @param aReferenceOnly avoids taking ownership of settings stored in project if true
*/
void SetProject( PROJECT* aProject );
void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
void ClearProject();