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 ) ...@@ -467,7 +467,7 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename )
* Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy. * 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 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 ) bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName )
...@@ -482,14 +482,17 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt ...@@ -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 if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) ) //do we reload the data from the existing hierarchy
{ {
msg.Printf( _( if(m_AssociatedScreen) //upon initial load, this will be null.
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ), {
aFileName.GetData() ); msg.Printf( _(
if( ! IsOK( NULL, msg ) ) "A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
{ aFileName.GetData() );
DisplayInfo(NULL, _("Sheet Filename Renaming Aborted")); if( ! IsOK( NULL, msg ) )
return false; {
} DisplayInfo(NULL, _("Sheet Filename Renaming Aborted"));
return false;
}
}
} }
else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file
......
...@@ -300,13 +300,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -300,13 +300,14 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
} }
ChangeFileNameExt( FileName, g_SchExtBuffer ); 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 = _("Changing a Filename can change all the schematic structure and cannot be undone" );
msg << wxT("\n"); msg << wxT("\n");
msg << _("Ok to continue renaming?"); 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_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName(m_Parent, FileName); 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