Give new sheets an initial name and filepath.

Fixes https://gitlab.com/kicad/code/kicad/issues/4516
This commit is contained in:
Jeff Young 2020-06-02 20:27:39 +01:00
parent 10add93d16
commit c01046c12f
2 changed files with 7 additions and 5 deletions

View File

@ -274,7 +274,7 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow()
bool filename_changed = oldFilename != newRelativeFilename; bool filename_changed = oldFilename != newRelativeFilename;
if( filename_changed ) if( filename_changed || m_sheet->IsNew() )
{ {
if( !onSheetFilenameChanged( newRelativeFilename ) ) if( !onSheetFilenameChanged( newRelativeFilename ) )
return false; return false;

View File

@ -996,13 +996,15 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
sheet = new SCH_SHEET( sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(),
m_frame->GetCurrentSheet().Last(), static_cast<wxPoint>( cursorPos ) ); static_cast<wxPoint>( cursorPos ) );
sheet->SetFlags( IS_NEW | IS_RESIZED ); sheet->SetFlags( IS_NEW | IS_RESIZED );
sheet->SetScreen( NULL ); sheet->SetScreen( NULL );
sheet->SetBorderWidth( cfg->m_Drawing.default_line_thickness ); sheet->SetBorderWidth( cfg->m_Drawing.default_line_thickness );
sheet->SetBorderColor( cfg->m_Drawing.default_sheet_border_color ); sheet->SetBorderColor( cfg->m_Drawing.default_sheet_border_color );
sheet->SetBackgroundColor( cfg->m_Drawing.default_sheet_background_color ); sheet->SetBackgroundColor( cfg->m_Drawing.default_sheet_background_color );
sheet->GetFields()[ SHEETNAME ].SetText( _( "Untitled Sheet" ) );
sheet->GetFields()[ SHEETFILENAME ].SetText( _( "untitled.kicad_sch" ) );
sizeSheet( sheet, cursorPos ); sizeSheet( sheet, cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
@ -1016,8 +1018,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
getViewControls()->SetAutoPan( false ); getViewControls()->SetAutoPan( false );
getViewControls()->CaptureCursor( false ); getViewControls()->CaptureCursor( false );
if( m_frame->EditSheetProperties( if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
static_cast<SCH_SHEET*>( sheet ), &m_frame->GetCurrentSheet(), nullptr ) ) &m_frame->GetCurrentSheet(), nullptr ) )
{ {
sheet->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); sheet->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );