diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 306f7b73d6..713ff38528 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -379,7 +379,8 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) } -std::string FormatProbeItem( EDA_ITEM* aItem, SCH_SYMBOL* aSymbol ) +std::string FormatProbeItem( const SCH_SHEET_PATH& aCurrentSheet, EDA_ITEM* aItem, + SCH_SYMBOL* aSymbol ) { // This is a keyword followed by a quoted string. @@ -403,20 +404,8 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_SYMBOL* aSymbol ) { // For cross probing, we need the full path of the sheet, because // in complex hierarchies the sheet uuid of not unique - SCH_SHEET* sheet = (SCH_SHEET*)aItem; - wxString full_path; - SCH_SHEET* parent = sheet; - while( (parent = dynamic_cast( parent->GetParent() ) ) ) - { - if( parent->GetParent() ) // The root sheet has no parent and path is just "/" - { - full_path.Prepend( parent->m_Uuid.AsString() ); - full_path.Prepend( "/" ); - } - } - - full_path += "/" + sheet->m_Uuid.AsString(); + wxString full_path = aCurrentSheet.PathAsString() + aItem->m_Uuid.AsString(); return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) ); } @@ -454,7 +443,7 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_SYMBOL* a if( !aObjectToSync ) return; - std::string packet = FormatProbeItem( aObjectToSync, aLibItem ); + std::string packet = FormatProbeItem( GetCurrentSheet(), aObjectToSync, aLibItem ); if( !packet.empty() ) { diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index a9954d61c0..671dde8a06 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -1366,7 +1366,7 @@ void PCB_SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath ) if( aSheetPath.IsEmpty() ) aSheetPath += '/'; - if( footprint_path == aSheetPath ) + if( footprint_path.StartsWith( aSheetPath ) ) footprintList.push_back( footprint ); } diff --git a/pcbnew/tools/pcb_selection_tool.h b/pcbnew/tools/pcb_selection_tool.h index 614a2058d7..9d0611f6cd 100644 --- a/pcbnew/tools/pcb_selection_tool.h +++ b/pcbnew/tools/pcb_selection_tool.h @@ -315,7 +315,7 @@ private: void selectAllItemsOnNet( int aNetCode, bool aSelect = true ); /** - * Select all items with the given sheet timestamp/UUID name (the sheet path). + * Select all items on a sheet and its subsheets, given the full sheet path. * * The path of the root sheet is "/". */