diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index d5d9db25ad..457b482e19 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -1990,7 +1990,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu SCH_ITEM* net_item = nullptr; SCH_ITEM* bus_item = nullptr; - SCH_CONNECTION conn; + SCH_CONNECTION conn( this ); for( auto item : aSubgraph->m_items ) { diff --git a/eeschema/dialogs/dialog_migrate_buses.cpp b/eeschema/dialogs/dialog_migrate_buses.cpp index a8974fbbbd..1339dcf872 100644 --- a/eeschema/dialogs/dialog_migrate_buses.cpp +++ b/eeschema/dialogs/dialog_migrate_buses.cpp @@ -122,15 +122,17 @@ void DIALOG_MIGRATE_BUSES::updateUi() } -std::vector DIALOG_MIGRATE_BUSES::getProposedLabels( const std::vector& aLabelList ) +std::vector DIALOG_MIGRATE_BUSES::getProposedLabels( + const std::vector& aLabelList ) { int lowest_start = INT_MAX; int highest_end = -1; int widest_bus = -1; + SCH_CONNECTION conn( m_frame->Schematic().ConnectionGraph() ); + for( const wxString& label : aLabelList ) { - SCH_CONNECTION conn; conn.ConfigureFromLabel( label ); int start = conn.VectorStart(); @@ -146,7 +148,6 @@ std::vector DIALOG_MIGRATE_BUSES::getProposedLabels( const std::vector widest_bus = end - start + 1; } - SCH_CONNECTION conn; std::vector proposals; for( const wxString& label : aLabelList ) diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 69820e9919..2bc3d5a79f 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -503,7 +503,9 @@ RESCUER::RESCUER( PROJECT& aProject, SCHEMATIC* aSchematic, SCH_SHEET_PATH* aCur wxASSERT( m_schematic ); - get_components( m_schematic, m_components ); + if( m_schematic ) + get_components( m_schematic, m_components ); + m_prj = &aProject; m_currentSheet = aCurrentSheet; m_galBackEndType = aGalBackEndType; diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index d6a8c1d765..313a6bfab4 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -60,7 +60,17 @@ SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) : m_sheet( aPath ), - m_parent( aParent ) + m_parent( aParent ), + m_graph( nullptr ) +{ + Reset(); +} + + +SCH_CONNECTION::SCH_CONNECTION( CONNECTION_GRAPH* aGraph ) : + m_sheet( SCH_SHEET_PATH() ), + m_parent( nullptr ), + m_graph( aGraph ) { Reset(); } diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index c9ed9a2993..d306c86853 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -63,6 +63,8 @@ class SCH_CONNECTION public: SCH_CONNECTION( SCH_ITEM* aParent = nullptr, SCH_SHEET_PATH aPath = SCH_SHEET_PATH() ); + SCH_CONNECTION( CONNECTION_GRAPH* aGraph ); + ~SCH_CONNECTION() {} diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 43e8abb5dd..812de3dfe3 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -358,6 +358,7 @@ SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN() m_kiway = nullptr; m_rootSheet = nullptr; m_currentSheet = nullptr; + m_schematic = nullptr; } diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 73aa54b3ed..23b3c26cff 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -578,12 +578,13 @@ SCH_LEGACY_PLUGIN::~SCH_LEGACY_PLUGIN() void SCH_LEGACY_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties ) { - m_version = 0; - m_rootSheet = NULL; - m_props = aProperties; - m_kiway = aKiway; - m_cache = NULL; - m_out = NULL; + m_version = 0; + m_rootSheet = nullptr; + m_props = aProperties; + m_kiway = aKiway; + m_cache = nullptr; + m_out = nullptr; + m_schematic = nullptr; } @@ -640,6 +641,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, SC // If we got here, the schematic loaded successfully. sheet = newSheet.release(); + m_rootSheet = nullptr; // Quiet Coverity warning. } else { diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 9e85d63658..7c3702165f 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1294,7 +1294,12 @@ void SCH_SCREENS::ClearAnnotation() void SCH_SCREENS::ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetPathList ) { - SCHEMATIC* sch = GetFirst()->Schematic(); + SCH_SCREEN* first = GetFirst(); + + if( !first ) + return; + + SCHEMATIC* sch = first->Schematic(); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" ); @@ -1419,7 +1424,12 @@ void SCH_SCREENS::UpdateSymbolLinks( REPORTER* aReporter ) for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() ) screen->UpdateSymbolLinks( aReporter ); - SCHEMATIC* sch = GetFirst()->Schematic(); + SCH_SCREEN* first = GetFirst(); + + if( !first ) + return; + + SCHEMATIC* sch = first->Schematic(); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" ); @@ -1571,7 +1581,12 @@ bool SCH_SCREENS::CanCauseCaseSensitivityIssue( const wxString& aSchematicFileNa void SCH_SCREENS::BuildClientSheetPathList() { - SCHEMATIC* sch = GetFirst()->Schematic(); + SCH_SCREEN* first = GetFirst(); + + if( !first ) + return; + + SCHEMATIC* sch = first->Schematic(); wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" ); diff --git a/eeschema/sch_sexpr_plugin.cpp b/eeschema/sch_sexpr_plugin.cpp index 1b6071acc0..6ecce29a4c 100644 --- a/eeschema/sch_sexpr_plugin.cpp +++ b/eeschema/sch_sexpr_plugin.cpp @@ -409,13 +409,14 @@ SCH_SEXPR_PLUGIN::~SCH_SEXPR_PLUGIN() void SCH_SEXPR_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties ) { - m_version = 0; - m_rootSheet = NULL; - m_props = aProperties; - m_kiway = aKiway; - m_cache = NULL; - m_out = NULL; - m_fieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS + m_version = 0; + m_rootSheet = nullptr; + m_props = aProperties; + m_kiway = aKiway; + m_cache = nullptr; + m_out = nullptr; + m_fieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS + m_schematic = nullptr; } diff --git a/include/printout.h b/include/printout.h index 018822d15d..56412395b7 100644 --- a/include/printout.h +++ b/include/printout.h @@ -33,11 +33,12 @@ struct PRINTOUT_SETTINGS PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo ) : m_pageInfo( aPageInfo ) { - m_scale = 1.0; - m_titleBlock = false; - m_blackWhite = true; - m_pageCount = 0; - m_background = false; + m_scale = 1.0; + m_titleBlock = false; + m_blackWhite = true; + m_pageCount = 0; + m_background = false; + m_colorSettings = nullptr; } virtual ~PRINTOUT_SETTINGS() diff --git a/pcbnew/drc/drc_rule.h b/pcbnew/drc/drc_rule.h index cbc73d79b1..fa7a6e1eb9 100644 --- a/pcbnew/drc/drc_rule.h +++ b/pcbnew/drc/drc_rule.h @@ -59,7 +59,8 @@ class DRC_SELECTOR { public: DRC_SELECTOR() : - m_Priority( 1 ) + m_Priority( 1 ), + m_Rule( nullptr ) { } public: