Don't store address of temp object.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15517
This commit is contained in:
Jeff Young 2023-08-27 19:02:12 +01:00
parent a470cab7b2
commit b5dc9ddbe0
4 changed files with 11 additions and 11 deletions

View File

@ -490,8 +490,8 @@ void SCH_COMMIT::Revert()
if( field->GetId() == REFERENCE_FIELD )
{
symbol->SetRef( schematic->GetSheets().FindSheetForScreen( screen ),
field->GetText() );
SCH_SHEET_PATH sheet = schematic->GetSheets().FindSheetForScreen( screen );
symbol->SetRef( &sheet, field->GetText() );
}
}

View File

@ -1045,15 +1045,15 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForPath( const SCH_SHEET_PATH* aPath )
}
SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForScreen( const SCH_SCREEN* aScreen )
SCH_SHEET_PATH SCH_SHEET_LIST::FindSheetForScreen( const SCH_SCREEN* aScreen )
{
for( SCH_SHEET_PATH& sheetpath : *this )
{
if( sheetpath.LastScreen() == aScreen )
return &sheetpath;
return sheetpath;
}
return nullptr;
return SCH_SHEET_PATH();
}

View File

@ -573,10 +573,10 @@ public:
SCH_SHEET_PATH* FindSheetForPath( const SCH_SHEET_PATH* aPath );
/**
* Return a pointer to the first #SCH_SHEET_PATH object (not necessarily the only one) using
* a particular screen.
* Return the first #SCH_SHEET_PATH object (not necessarily the only one) using a particular
* screen.
*/
SCH_SHEET_PATH* FindSheetForScreen( const SCH_SCREEN* aScreen );
SCH_SHEET_PATH FindSheetForScreen( const SCH_SCREEN* aScreen );
/**
* Return a #SCH_SHEET_LIST with a copy of all the #SCH_SHEET_PATH using a particular screen.

View File

@ -313,7 +313,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
}
else if( status == UNDO_REDO::PAGESETTINGS )
{
SCH_SHEET_PATH& undoSheet = *m_schematic->GetSheets().FindSheetForScreen( screen );
SCH_SHEET_PATH undoSheet = m_schematic->GetSheets().FindSheetForScreen( screen );
if( GetCurrentSheet() != undoSheet )
{
@ -355,8 +355,8 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
if( field->GetId() == REFERENCE_FIELD )
{
symbol->SetRef( m_schematic->GetSheets().FindSheetForScreen( screen ),
field->GetText() );
SCH_SHEET_PATH sheet = m_schematic->GetSheets().FindSheetForScreen( screen );
symbol->SetRef( &sheet, field->GetText() );
}
bulkChangedItems.emplace_back( symbol );