Commit c86da05a authored by lifekidyeaa's avatar lifekidyeaa

fixed error in eeschema: when loading a new sub-sheet, it incorrectly asked if the user wanted

to change the sheet.  there is no 'change' since the sheet is new, and the associated screen 
should either be loaded from the hierarchy or from a file. 
parent 81b6cbcb
......@@ -467,7 +467,7 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename )
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : add the sheet to the complex hierarchy.
* - if new filename is already used (a complex hierarchy) : reference the sheet.
*/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName )
......@@ -482,14 +482,17 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) ) //do we reload the data from the existing hierarchy
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( ! IsOK( NULL, msg ) )
{
DisplayInfo(NULL, _("Sheet Filename Renaming Aborted"));
return false;
}
if(m_AssociatedScreen) //upon initial load, this will be null.
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( ! IsOK( NULL, msg ) )
{
DisplayInfo(NULL, _("Sheet Filename Renaming Aborted"));
return false;
}
}
}
else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file
......
......@@ -300,13 +300,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
}
ChangeFileNameExt( FileName, g_SchExtBuffer );
if ( (FileName != m_CurrentSheet->GetFileName()) && m_CurrentSheet->m_AssociatedScreen )
if ( (FileName != m_CurrentSheet->GetFileName()) )
{
msg = _("Changing a Filename can change all the schematic structure and cannot be undone" );
msg << wxT("\n");
msg << _("Ok to continue renaming?");
if( IsOK( NULL, msg) )
{
if( m_CurrentSheet->m_AssociatedScreen == 0 || IsOK( NULL, msg) )
{ //do not prompt on a new sheet. in fact, we should not allow a sheet to be created
//without a valid associated filename to be read from.
m_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName(m_Parent, FileName);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment