Browse Source

Prevent crash when importing over existing project

If the hierarchy navigator is open and expanded, we have references to
the existing sheets.  These need to be cleared when importing a new
sheet over top

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20004
revert-0c36e162
Seth Hillbrand 9 months ago
parent
commit
2e93fb7a24
  1. 4
      eeschema/files-io.cpp
  2. 4
      eeschema/sch_edit_frame.cpp
  3. 2
      eeschema/sch_edit_frame.h
  4. 6
      eeschema/widgets/hierarchy_pane.cpp
  5. 2
      eeschema/widgets/hierarchy_pane.h

4
eeschema/files-io.cpp

@ -578,7 +578,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
TestDanglingEnds();
UpdateHierarchyNavigator( false );
UpdateHierarchyNavigator( false, true );
wxCommandEvent changedEvt( EDA_EVT_SCHEMATIC_CHANGED );
ProcessEventLocally( changedEvt );
@ -1424,7 +1424,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType,
SetSheetNumberAndCount();
SyncView();
UpdateHierarchyNavigator();
UpdateHierarchyNavigator( false, true );
wxCommandEvent e( EDA_EVT_SCHEMATIC_CHANGED );
ProcessEventLocally( e );

4
eeschema/sch_edit_frame.cpp

@ -1229,10 +1229,10 @@ void SCH_EDIT_FRAME::OnUpdatePCB()
}
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator )
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
{
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
m_hierarchy->UpdateHierarchyTree();
m_hierarchy->UpdateHierarchyTree( aClear );
if( aRefreshNetNavigator )
RefreshNetNavigator();

2
eeschema/sch_edit_frame.h

@ -244,7 +244,7 @@ public:
/**
* Update the hierarchy navigation tree and history
*/
void UpdateHierarchyNavigator( bool aRefreshNetNavigator = true );
void UpdateHierarchyNavigator( bool aRefreshNetNavigator = true, bool aClear = false );
/**
* Update the hierarchy navigation tree labels.

6
eeschema/widgets/hierarchy_pane.cpp

@ -209,7 +209,7 @@ void HIERARCHY_PANE::UpdateHierarchySelection()
}
void HIERARCHY_PANE::UpdateHierarchyTree()
void HIERARCHY_PANE::UpdateHierarchyTree( bool aClear )
{
Freeze();
@ -248,7 +248,9 @@ void HIERARCHY_PANE::UpdateHierarchyTree()
}
};
if( !m_tree->IsEmpty() )
// If we are clearing the tree, don't try to get expanded nodes as they
// might be deleted
if( !aClear && !m_tree->IsEmpty() )
getExpandedNodes( m_tree->GetRootItem() );
m_list.clear();

2
eeschema/widgets/hierarchy_pane.h

@ -84,7 +84,7 @@ public:
/**
* Update the hierarchical tree of the schematic.
*/
void UpdateHierarchyTree();
void UpdateHierarchyTree( bool aClear = false );
/**
* Updates the tree's selection to match current page

Loading…
Cancel
Save