diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index c56bc151d5..95e05a6f2d 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -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(); + selTool->ClearSelection(); + wxBusyCursor dummy; // Undraw old zone outlines diff --git a/pcbnew/zone_manager/dialog_zone_manager.cpp b/pcbnew/zone_manager/dialog_zone_manager.cpp index a2d195e30c..2741c24e14 100644 --- a/pcbnew/zone_manager/dialog_zone_manager.cpp +++ b/pcbnew/zone_manager/dialog_zone_manager.cpp @@ -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 ); diff --git a/pcbnew/zone_manager/dialog_zone_manager.h b/pcbnew/zone_manager/dialog_zone_manager.h index d57c0ef33b..ef0c5b5bea 100644 --- a/pcbnew/zone_manager/dialog_zone_manager.h +++ b/pcbnew/zone_manager/dialog_zone_manager.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 Ethan Chien - * 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 ); diff --git a/pcbnew/zone_manager/dialog_zone_manager_base.cpp b/pcbnew/zone_manager/dialog_zone_manager_base.cpp index 214daba065..00c905ee8e 100644 --- a/pcbnew/zone_manager/dialog_zone_manager_base.cpp +++ b/pcbnew/zone_manager/dialog_zone_manager_base.cpp @@ -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 ); } diff --git a/pcbnew/zone_manager/dialog_zone_manager_base.fbp b/pcbnew/zone_manager/dialog_zone_manager_base.fbp index 0ab7d367c3..541b35386b 100644 --- a/pcbnew/zone_manager/dialog_zone_manager_base.fbp +++ b/pcbnew/zone_manager/dialog_zone_manager_base.fbp @@ -688,6 +688,7 @@ m_sdbSizer protected + OnOk diff --git a/pcbnew/zone_manager/dialog_zone_manager_base.h b/pcbnew/zone_manager/dialog_zone_manager_base.h index 113598e717..9ce2572506 100644 --- a/pcbnew/zone_manager/dialog_zone_manager_base.h +++ b/pcbnew/zone_manager/dialog_zone_manager_base.h @@ -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: