destroy window when list nets dialog is closed

avoid potential performance issues when the dialog is still listening to
the board updates and refreshing its data and view structures.

it seems useful to keep the settings of the dialog across dialog
open-close cycles.
This commit is contained in:
Oleg Endo 2020-04-13 20:54:35 +09:00 committed by Jon Evans
parent 980f4a1f6a
commit 80e40b862c
4 changed files with 50 additions and 8 deletions

View File

@ -119,8 +119,9 @@ struct DIALOG_SELECT_NET_FROM_LIST::ROW_DESC
};
DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent )
: DIALOG_SELECT_NET_FROM_LIST_BASE( aParent ), m_frame( aParent )
DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST(
PCB_EDIT_FRAME* aParent, const SETTINGS& aSettings )
: DIALOG_SELECT_NET_FROM_LIST_BASE( aParent ), m_frame( aParent )
{
m_brd = aParent->GetBoard();
m_wasSelected = false;
@ -144,6 +145,9 @@ DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParen
// expander buttons... but it doesn't. Fix by forcing the indent to 0.
m_netsList->SetIndent( 0 );
m_textCtrlFilter->SetValue( aSettings.filter_string );
m_cbShowZeroPad->SetValue( aSettings.show_zero_pad_nets );
buildNetsList();
adjustListColumns();
@ -181,9 +185,14 @@ DIALOG_SELECT_NET_FROM_LIST::~DIALOG_SELECT_NET_FROM_LIST()
m_brd->RemoveListener( this );
}
DIALOG_SELECT_NET_FROM_LIST::SETTINGS DIALOG_SELECT_NET_FROM_LIST::Settings() const
{
return { m_textCtrlFilter->GetValue(), m_cbShowZeroPad->IsChecked() };
}
void DIALOG_SELECT_NET_FROM_LIST::onParentWindowClosed( wxCommandEvent& event )
{
Close();
event.Skip();
}

View File

@ -36,9 +36,17 @@ class CN_ITEM;
class DIALOG_SELECT_NET_FROM_LIST : public DIALOG_SELECT_NET_FROM_LIST_BASE, public BOARD_LISTENER
{
public:
DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent );
struct SETTINGS
{
wxString filter_string;
bool show_zero_pad_nets = true;
};
DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent, const SETTINGS& aSettings );
~DIALOG_SELECT_NET_FROM_LIST();
SETTINGS Settings() const;
// returns true if a net was selected, and its name in aName
bool GetNetName( wxString& aName ) const;

View File

@ -28,7 +28,6 @@
#include <tools/edit_tool.h>
#include <painter.h>
#include <connectivity/connectivity_data.h>
#include <dialogs/dialog_select_net_from_list.h>
#include <profile.h>
#include "pcb_inspection_tool.h"
@ -448,13 +447,37 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest()
int PCB_INSPECTION_TOOL::ListNets( const TOOL_EVENT& aEvent )
{
if( m_listNetsDialog == nullptr )
m_listNetsDialog = std::make_unique<DIALOG_SELECT_NET_FROM_LIST>( m_frame );
{
m_listNetsDialog =
std::make_unique<DIALOG_SELECT_NET_FROM_LIST>( m_frame, m_listNetsDialogSettings );
m_listNetsDialog->Connect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
this );
m_listNetsDialog->Connect( wxEVT_BUTTON,
wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
this );
}
m_listNetsDialog->Show( true );
return 0;
}
void PCB_INSPECTION_TOOL::onListNetsDialogClosed( wxCommandEvent& event )
{
m_listNetsDialogSettings = m_listNetsDialog->Settings();
m_listNetsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
m_listNetsDialog->Disconnect( wxEVT_BUTTON,
wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
m_listNetsDialog->Destroy();
m_listNetsDialog.release();
}
void PCB_INSPECTION_TOOL::setTransitions()
{
Go( &PCB_INSPECTION_TOOL::CrossProbePcbToSch, EVENTS::SelectedEvent );

View File

@ -26,12 +26,11 @@
#include <dialogs/dialog_board_statistics.h>
#include <dialogs/dialog_select_net_from_list.h>
#include <pcb_edit_frame.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_tool_base.h>
class DIALOG_SELECT_NET_FROM_LIST;
/**
* PCB_INSPECTION_TOOL
*
@ -95,6 +94,8 @@ private:
///> Bind handlers to corresponding TOOL_ACTIONs
void setTransitions() override;
void onListNetsDialogClosed( wxCommandEvent& event );
private:
PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
@ -105,6 +106,7 @@ private:
wxTimer m_ratsnestTimer; // Timer to initiate lazy ratsnest calculation (ie: when slow)
std::unique_ptr<DIALOG_SELECT_NET_FROM_LIST> m_listNetsDialog;
DIALOG_SELECT_NET_FROM_LIST::SETTINGS m_listNetsDialogSettings;
};
#endif //__BOARD_STATISTICS_TOOL_H