From 1e505d4c228a29431948207ada3caf1a9fcb79c1 Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Mon, 18 Apr 2022 07:57:35 +0200 Subject: [PATCH] Remove a few call sites of SCH_SHEET::SetSize This function is dangerous and should be used only by parsers, and not even those, really. For new objects, the size can be passed to the constructor. --- eeschema/dialogs/panel_eeschema_color_settings.cpp | 6 ++++-- eeschema/sch_plugins/altium/sch_altium_plugin.cpp | 6 ++++-- eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index cd9cda6ab1..e421567766 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -424,8 +424,10 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() addItem( symbol ); } - SCH_SHEET* s = new SCH_SHEET( nullptr, MILS_POINT( 4000, 1300 ) ); - s->SetSize( wxSize( Mils2iu( 800 ), Mils2iu( 1300 ) ) ); + SCH_SHEET* s = new SCH_SHEET( + /* aParent */ nullptr, + /* aPosition */ MILS_POINT( 4000, 1300 ), + /* aSize */ wxSize( Mils2iu( 800 ), Mils2iu( 1300 ) ) ); s->GetFields().at( SHEETNAME ).SetText( wxT( "SHEET" ) ); s->GetFields().at( SHEETFILENAME ).SetText( _( "/path/to/sheet" ) ); s->AutoplaceFields( nullptr, false ); diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 6d33cbd237..388ee4df84 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -1457,10 +1457,12 @@ void SCH_ALTIUM_PLUGIN::ParseSheetSymbol( int aIndex, { ASCH_SHEET_SYMBOL elem( aProperties ); - SCH_SHEET* sheet = new SCH_SHEET( m_currentSheet, elem.location + m_sheetOffset ); + SCH_SHEET* sheet = new SCH_SHEET( + /* aParent */ m_currentSheet, + /* aPosition */ elem.location + m_sheetOffset, + /* aSize */ elem.size ); SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); - sheet->SetSize( elem.size ); sheet->SetBorderColor( GetColorFromInt( elem.color ) ); if( elem.isSolid ) diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index b1948bd6d7..e2f0abfc4d 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -2141,11 +2141,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( LAYER_ID wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), , "Sheet already loaded!" ); - SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition ); + SCH_SHEET* sheet = new SCH_SHEET( + /* aParent */ aParentSheet.Last(), + /* aPosition */ aPosition, + /* aSize */ wxSize( aSheetSize ) ); SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); SCH_SHEET_PATH instance( aParentSheet ); - sheet->SetSize( (wxSize) aSheetSize ); sheet->SetScreen( screen ); wxString name = Sheets.SheetNames.at( aCadstarSheetID );