Clear annotation of pasted sheets only when they already exist in the current hierarchy.
Fixes: lp:1833205 * https://bugs.launchpad.net/kicad/+bug/1833205
This commit is contained in:
parent
8d84e22f31
commit
c77d214c5f
|
@ -670,7 +670,7 @@ void SCH_LEGACY_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
|||
wxLogTrace( traceSchLegacyPlugin, "Current path \"%s\"", m_currentPath.top() );
|
||||
wxLogTrace( traceSchLegacyPlugin, "Loading \"%s\"", fileName.GetFullPath() );
|
||||
|
||||
m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
|
||||
m_rootSheet->SearchHierarchy( fileName.GetFullPath( wxPATH_UNIX ), &screen );
|
||||
|
||||
if( screen )
|
||||
{
|
||||
|
|
|
@ -548,18 +548,22 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
|||
{
|
||||
if( item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
// Must use the screen's path (which is always absolute) rather than the
|
||||
// sheet's (which could be relative).
|
||||
|
||||
if( sheet->m_screen
|
||||
&& sheet->m_screen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
SCH_SCREEN* screen = sheet->m_screen;
|
||||
|
||||
if( screen && screen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
||||
{
|
||||
*aScreen = sheet->m_screen;
|
||||
*aScreen = screen;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
||||
else if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
item = item->Next();
|
||||
}
|
||||
|
|
|
@ -418,7 +418,7 @@ public:
|
|||
/**
|
||||
* Search the existing hierarchy for an instance of screen loaded from \a aFileName.
|
||||
*
|
||||
* @param aFilename = the filename to find
|
||||
* @param aFilename = the filename to find (MUST be absolute, and in wxPATH_UNIX encoding)
|
||||
* @param aScreen = a location to return a pointer to the screen (if found)
|
||||
* @return bool if found, and a pointer to the screen
|
||||
*/
|
||||
|
|
|
@ -131,10 +131,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
|||
"Cannot normalize new sheet schematic file path." );
|
||||
}
|
||||
|
||||
wxString newFilename = fileName.GetFullPath();
|
||||
wxString newFilename = fileName.GetFullPath( wxPATH_UNIX );
|
||||
|
||||
// Search for a schematic file having the same filename
|
||||
// already in use in the hierarchy or on disk, in order to reuse it.
|
||||
// Search for a schematic file having the same filename already in use in the hierarchy
|
||||
// or on disk, in order to reuse it.
|
||||
if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
|
||||
{
|
||||
loadFromFile = wxFileExists( newFilename );
|
||||
|
|
|
@ -833,8 +833,6 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
//
|
||||
bool sheetsPasted = false;
|
||||
SCH_SHEET_LIST hierarchy( g_RootSheet );
|
||||
SCH_SHEET_LIST initialHierarchy( g_RootSheet );
|
||||
|
||||
wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
|
||||
|
||||
if( destFn.IsRelative() )
|
||||
|
@ -909,13 +907,34 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
else if( item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
wxFileName fn = sheet->GetFileName();
|
||||
SCH_SCREEN* existingScreen = nullptr;
|
||||
|
||||
if( g_RootSheet->SearchHierarchy( sheet->GetFileName(), &existingScreen ) )
|
||||
if( !fn.IsAbsolute() )
|
||||
{
|
||||
wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
|
||||
fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
|
||||
}
|
||||
|
||||
if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
|
||||
{
|
||||
sheet->SetScreen( existingScreen );
|
||||
|
||||
SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
|
||||
sheetpath.push_back( sheet );
|
||||
|
||||
// Clear annotation and create the AR for this path, if not exists,
|
||||
// when the screen is shared by sheet paths.
|
||||
// Otherwise ClearAnnotation do nothing, because the F1 field is used as
|
||||
// reference default value and takes the latest displayed value
|
||||
existingScreen->EnsureAlternateReferencesExist();
|
||||
existingScreen->ClearAnnotation( &sheetpath );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, sheet->GetFileName() );
|
||||
}
|
||||
}
|
||||
|
||||
item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
|
||||
m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
|
||||
|
@ -925,12 +944,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
if( sheetsPasted )
|
||||
{
|
||||
// We clear annotation of new sheet paths.
|
||||
SCH_SCREENS screensList( g_RootSheet );
|
||||
screensList.ClearAnnotationOfNewSheetPaths( initialHierarchy );
|
||||
m_frame->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
// Now clear the previous selection, select the pasted items, and fire up the "move"
|
||||
// tool.
|
||||
|
|
Loading…
Reference in New Issue