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, "Current path \"%s\"", m_currentPath.top() );
|
||||||
wxLogTrace( traceSchLegacyPlugin, "Loading \"%s\"", fileName.GetFullPath() );
|
wxLogTrace( traceSchLegacyPlugin, "Loading \"%s\"", fileName.GetFullPath() );
|
||||||
|
|
||||||
m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
|
m_rootSheet->SearchHierarchy( fileName.GetFullPath( wxPATH_UNIX ), &screen );
|
||||||
|
|
||||||
if( screen )
|
if( screen )
|
||||||
{
|
{
|
||||||
|
|
|
@ -548,17 +548,21 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
||||||
{
|
{
|
||||||
if( item->Type() == SCH_SHEET_T )
|
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
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||||
&& sheet->m_screen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
SCH_SCREEN* screen = sheet->m_screen;
|
||||||
|
|
||||||
|
if( screen && screen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
||||||
{
|
{
|
||||||
*aScreen = sheet->m_screen;
|
*aScreen = screen;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
||||||
if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item = item->Next();
|
item = item->Next();
|
||||||
|
|
|
@ -418,7 +418,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Search the existing hierarchy for an instance of screen loaded from \a aFileName.
|
* 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)
|
* @param aScreen = a location to return a pointer to the screen (if found)
|
||||||
* @return bool if found, and a pointer to the screen
|
* @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." );
|
"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
|
// Search for a schematic file having the same filename already in use in the hierarchy
|
||||||
// already in use in the hierarchy or on disk, in order to reuse it.
|
// or on disk, in order to reuse it.
|
||||||
if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
|
if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
|
||||||
{
|
{
|
||||||
loadFromFile = wxFileExists( newFilename );
|
loadFromFile = wxFileExists( newFilename );
|
||||||
|
|
|
@ -833,8 +833,6 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
//
|
//
|
||||||
bool sheetsPasted = false;
|
bool sheetsPasted = false;
|
||||||
SCH_SHEET_LIST hierarchy( g_RootSheet );
|
SCH_SHEET_LIST hierarchy( g_RootSheet );
|
||||||
SCH_SHEET_LIST initialHierarchy( g_RootSheet );
|
|
||||||
|
|
||||||
wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
|
wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
|
||||||
|
|
||||||
if( destFn.IsRelative() )
|
if( destFn.IsRelative() )
|
||||||
|
@ -909,12 +907,33 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
else if( item->Type() == SCH_SHEET_T )
|
else if( item->Type() == SCH_SHEET_T )
|
||||||
{
|
{
|
||||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||||
|
wxFileName fn = sheet->GetFileName();
|
||||||
SCH_SCREEN* existingScreen = nullptr;
|
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 );
|
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
|
else
|
||||||
|
{
|
||||||
m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, sheet->GetFileName() );
|
m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, sheet->GetFileName() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
|
item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
|
||||||
|
@ -925,12 +944,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sheetsPasted )
|
if( sheetsPasted )
|
||||||
{
|
|
||||||
// We clear annotation of new sheet paths.
|
|
||||||
SCH_SCREENS screensList( g_RootSheet );
|
|
||||||
screensList.ClearAnnotationOfNewSheetPaths( initialHierarchy );
|
|
||||||
m_frame->SetSheetNumberAndCount();
|
m_frame->SetSheetNumberAndCount();
|
||||||
}
|
|
||||||
|
|
||||||
// Now clear the previous selection, select the pasted items, and fire up the "move"
|
// Now clear the previous selection, select the pasted items, and fire up the "move"
|
||||||
// tool.
|
// tool.
|
||||||
|
|
Loading…
Reference in New Issue