KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue20173_paste_subsheet.cpp File Reference

Test for issue #20173: Copy/paste subsheet causes original sheet's references to be corrupted. More...

Go to the source code of this file.

Classes

struct  ISSUE20173_FIXTURE
 

Functions

std::map< KIID, wxString > GetSymbolReferences (const SCH_SHEET_PATH &aPath)
 Helper function to get all symbol references for a given sheet path.
 
 BOOST_FIXTURE_TEST_CASE (Issue20173PruningAfterPaste, ISSUE20173_FIXTURE)
 Test that simulates the paste flow more closely, including instance pruning.
 
 BOOST_FIXTURE_TEST_CASE (Issue20173ClearAnnotationFieldCorruption, ISSUE20173_FIXTURE)
 Test that ClearAnnotation doesn't corrupt REFERENCE field in a way that affects GetRef.
 
 BOOST_FIXTURE_TEST_CASE (Issue20173FieldTextCorruption, ISSUE20173_FIXTURE)
 Test that reproduces the actual bug: ClearAnnotation corrupts field text.
 
 BOOST_FIXTURE_TEST_CASE (Issue20173SharedScreenInstances, ISSUE20173_FIXTURE)
 Test that symbols on a shared screen maintain independent instances for each sheet path.
 

Detailed Description

Test for issue #20173: Copy/paste subsheet causes original sheet's references to be corrupted.

The test verifies that when a subsheet is copy/pasted to create a second instance sharing the same screen file, the original sheet's symbol references are preserved correctly.

Bug scenario:

  • Start with a root sheet containing subsheet CH1 with symbols R1, R2, R3, R4, D1, D2
  • Copy/paste CH1 to create CH2 (which shares the same screen as CH1)
  • CH2 gets new references: R5...R8, D3, D4 (via annotation)
  • BUG: When navigating back to CH1, references show R5...R8, D3, D4 instead of R1...R4, D1, D2

Root cause: When a shared screen is used, symbol instances for the original path may be incorrectly modified or lost during the paste operation.

Definition in file test_issue20173_paste_subsheet.cpp.

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/4]

BOOST_FIXTURE_TEST_CASE ( Issue20173ClearAnnotationFieldCorruption ,
ISSUE20173_FIXTURE  )

Test that ClearAnnotation doesn't corrupt REFERENCE field in a way that affects GetRef.

ClearAnnotation modifies both the instance reference AND the REFERENCE field text. If GetRef falls back to the field text (when instance doesn't match), this can cause issues.

Definition at line 255 of file test_issue20173_paste_subsheet.cpp.

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), SCH_SYMBOL::ClearAnnotation(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SYMBOL::GetRef(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, REFERENCE, SCH_SYMBOL_T, SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, and SCH_SHEET_PATH::size().

◆ BOOST_FIXTURE_TEST_CASE() [2/4]

BOOST_FIXTURE_TEST_CASE ( Issue20173FieldTextCorruption ,
ISSUE20173_FIXTURE  )

Test that reproduces the actual bug: ClearAnnotation corrupts field text.

When ClearAnnotation is called for a specific path (CH2), it incorrectly modifies the REFERENCE field text. If GetRef later falls back to field text (due to mismatched instance paths), it returns the corrupted value.

Definition at line 379 of file test_issue20173_paste_subsheet.cpp.

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), SCH_SYMBOL::ClearAnnotation(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, REFERENCE, SCH_SYMBOL_T, SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, and SCH_SHEET_PATH::size().

◆ BOOST_FIXTURE_TEST_CASE() [3/4]

BOOST_FIXTURE_TEST_CASE ( Issue20173PruningAfterPaste ,
ISSUE20173_FIXTURE  )

◆ BOOST_FIXTURE_TEST_CASE() [4/4]

◆ GetSymbolReferences()

std::map< KIID, wxString > GetSymbolReferences ( const SCH_SHEET_PATH & aPath)

Helper function to get all symbol references for a given sheet path.

Returns a map of symbol UUID -> reference designator.

Definition at line 68 of file test_issue20173_paste_subsheet.cpp.

References SCH_SYMBOL::GetRef(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), and SCH_SYMBOL_T.