From 2764f292cb87c035e294609a8dde2bdb48a2882f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 27 Aug 2023 19:02:12 +0100 Subject: [PATCH] Don't store address of temp object. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15517 --- eeschema/sch_sheet_path.cpp | 6 +++--- eeschema/sch_sheet_path.h | 6 +++--- eeschema/schematic_undo_redo.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index e7214b9405..bf60ee3c10 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -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(); } diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 048a4d42b6..5525135830 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -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. diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 8ffa254654..04ba5c6279 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -301,7 +301,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 ) { @@ -339,8 +339,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() ); } }