eeschema: fix use-after-free crash in GetScreen()/GetCurrentSheet()
This commit is contained in:
parent
034669bf30
commit
aff3243f3b
|
@ -239,7 +239,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
{
|
{
|
||||||
SetScreen( nullptr );
|
SetScreen( nullptr );
|
||||||
delete g_RootSheet;
|
delete g_RootSheet;
|
||||||
g_RootSheet = NULL;
|
if( g_CurrentSheet )
|
||||||
|
g_CurrentSheet->clear();
|
||||||
|
g_RootSheet = nullptr;
|
||||||
|
|
||||||
CreateScreens();
|
CreateScreens();
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,12 +489,18 @@ void SCH_EDIT_FRAME::SetSheetNumberAndCount()
|
||||||
|
|
||||||
SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
|
SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
|
||||||
{
|
{
|
||||||
|
if( !g_CurrentSheet )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return g_CurrentSheet->LastScreen();
|
return g_CurrentSheet->LastScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_EDIT_FRAME::GetScreenDesc() const
|
wxString SCH_EDIT_FRAME::GetScreenDesc() const
|
||||||
{
|
{
|
||||||
|
if(! g_CurrentSheet )
|
||||||
|
return wxT("<unknown>");
|
||||||
|
|
||||||
wxString s = g_CurrentSheet->PathHumanReadable();
|
wxString s = g_CurrentSheet->PathHumanReadable();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -748,8 +754,12 @@ void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
|
void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
|
||||||
{
|
{
|
||||||
aEvent.Enable( GetScreen()->IsModify() );
|
auto screen = GetScreen();
|
||||||
|
|
||||||
|
if( !screen )
|
||||||
|
return;
|
||||||
|
|
||||||
|
aEvent.Enable( screen->IsModify() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
};
|
};
|
||||||
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
|
||||||
controls->SetSnapping( true );
|
controls->SetSnapping( true );
|
||||||
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
||||||
|
bool moveMode;
|
||||||
|
|
||||||
// Be sure that there is at least one item that we can move. If there's no selection try
|
// Be sure that there is at least one item that we can move. If there's no selection try
|
||||||
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
||||||
|
@ -463,7 +463,6 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
|
||||||
|
|
||||||
switch( test->Type() )
|
switch( test->Type() )
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case SCH_LINE_T:
|
case SCH_LINE_T:
|
||||||
{
|
{
|
||||||
// Select the connected end of wires/bus connections.
|
// Select the connected end of wires/bus connections.
|
||||||
|
|
Loading…
Reference in New Issue