7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 14:41:42 +00:00

DIALOG_ZONE_MANAGER: fix crash when modifying zones if a zone is selected

Looks like an issue in EDIT_POINT tool (dangling pointers?)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19131
This commit is contained in:
jean-pierre charras 2024-11-16 16:16:49 +01:00
parent 4dbe295e80
commit f354eca50e
6 changed files with 12 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -242,6 +242,11 @@ int GLOBAL_EDIT_TOOL::ZonesManager( const TOOL_EVENT& aEvent )
if( dialogResult == wxID_CANCEL )
return 0;
// Ensure all zones are deselected before make any change in view, to avoid
// dangling pointers in EDIT_POINT
PCB_SELECTION_TOOL* selTool = editFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
selTool->ClearSelection();
wxBusyCursor dummy;
// Undraw old zone outlines

View File

@ -103,7 +103,6 @@ DIALOG_ZONE_MANAGER::DIALOG_ZONE_MANAGER( PCB_BASE_FRAME* aParent, ZONE_SETTINGS
Bind( wxEVT_DATAVIEW_ITEM_DROP, &DIALOG_ZONE_MANAGER::OnDrop, this, id );
#endif // wxUSE_DRAG_AND_DROP
Bind( wxEVT_BUTTON, &DIALOG_ZONE_MANAGER::OnOk, this, wxID_OK );
Bind( EVT_ZONE_NAME_UPDATE, &DIALOG_ZONE_MANAGER::OnZoneNameUpdate, this );
Bind( EVT_ZONES_OVERVIEW_COUNT_CHANGE, &DIALOG_ZONE_MANAGER::OnZonesTableRowCountChange, this );
Bind( wxEVT_CHECKBOX, &DIALOG_ZONE_MANAGER::OnCheckBoxClicked, this );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 Ethan Chien <liangtie.qian@gmail.com>
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -77,7 +77,7 @@ protected:
void OnViewZonesOverviewOnLeftUp( wxMouseEvent& aEvent ) override;
void onDialogResize( wxSizeEvent& event ) override;
void OnOk( wxCommandEvent& aEvt );
void OnOk( wxCommandEvent& aEvt ) override;
#if wxUSE_DRAG_AND_DROP
void OnBeginDrag( wxDataViewEvent& aEvent );

View File

@ -122,6 +122,7 @@ DIALOG_ZONE_MANAGER_BASE::DIALOG_ZONE_MANAGER_BASE( wxWindow* parent, wxWindowID
m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnMoveDownClick ), NULL, this );
m_checkRepour->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnRepourCheck ), NULL, this );
m_updateDisplayedZones->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnUpdateDisplayedZonesClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnOk ), NULL, this );
}
DIALOG_ZONE_MANAGER_BASE::~DIALOG_ZONE_MANAGER_BASE()
@ -140,5 +141,6 @@ DIALOG_ZONE_MANAGER_BASE::~DIALOG_ZONE_MANAGER_BASE()
m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnMoveDownClick ), NULL, this );
m_checkRepour->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnRepourCheck ), NULL, this );
m_updateDisplayedZones->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnUpdateDisplayedZonesClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ZONE_MANAGER_BASE::OnOk ), NULL, this );
}

View File

@ -688,6 +688,7 @@
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnOKButtonClick">OnOk</event>
</object>
</object>
</object>

View File

@ -70,6 +70,7 @@ class DIALOG_ZONE_MANAGER_BASE : public DIALOG_SHIM
virtual void OnMoveDownClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRepourCheck( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateDisplayedZonesClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOk( wxCommandEvent& event ) { event.Skip(); }
public: