Prevent out of scope lambda use
Keeping a function reference is only in scope when the call is immediately executed, not when it enters its own event loop. This commit also excises one more onUpdateUI call as it is not needed Fixes https://gitlab.com/kicad/code/kicad/issues/12395
This commit is contained in:
parent
9894acea76
commit
3d3b7d839c
|
@ -75,43 +75,38 @@ bool DIALOG_ASSIGN_NETCLASS::TransferDataFromWindow()
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_ASSIGN_NETCLASS::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
void DIALOG_ASSIGN_NETCLASS::onPatternText( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxString pattern = m_patternCtrl->GetValue();
|
||||
|
||||
if( pattern != m_lastPattern )
|
||||
{
|
||||
CallAfter(
|
||||
[this, pattern]()
|
||||
m_matchingNets->Clear();
|
||||
|
||||
std::vector<wxString> matchingNetNames;
|
||||
|
||||
if( !pattern.IsEmpty() )
|
||||
{
|
||||
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
|
||||
|
||||
m_matchingNets->Report( _( "<b>Currently matching nets:</b>" ) );
|
||||
|
||||
for( const wxString& net : m_netCandidates )
|
||||
{
|
||||
int matches;
|
||||
int offset;
|
||||
|
||||
if( matcher.Find( net, matches, offset ) && offset == 0 )
|
||||
{
|
||||
m_matchingNets->Clear();
|
||||
m_matchingNets->Report( net );
|
||||
matchingNetNames.push_back( net );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<wxString> matchingNetNames;
|
||||
|
||||
if( !pattern.IsEmpty() )
|
||||
{
|
||||
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
|
||||
|
||||
m_matchingNets->Report( _( "<b>Currently matching nets:</b>" ) );
|
||||
|
||||
for( const wxString& net : m_netCandidates )
|
||||
{
|
||||
int matches;
|
||||
int offset;
|
||||
|
||||
if( matcher.Find( net, matches, offset ) && offset == 0 )
|
||||
{
|
||||
m_matchingNets->Report( net );
|
||||
matchingNetNames.push_back( net );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_matchingNets->Flush();
|
||||
|
||||
m_previewer( matchingNetNames );
|
||||
} );
|
||||
m_matchingNets->Flush();
|
||||
|
||||
m_previewer( matchingNetNames );
|
||||
m_lastPattern = pattern;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,12 +84,12 @@ DIALOG_ASSIGN_NETCLASS_BASE::DIALOG_ASSIGN_NETCLASS_BASE( wxWindow* parent, wxWi
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::OnUpdateUI ) );
|
||||
m_patternCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::onPatternText ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_ASSIGN_NETCLASS_BASE::~DIALOG_ASSIGN_NETCLASS_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::OnUpdateUI ) );
|
||||
m_patternCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::onPatternText ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnUpdateUI">OnUpdateUI</event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bMainSizer</property>
|
||||
|
@ -194,6 +193,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnText">onPatternText</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
|
|
@ -49,7 +49,7 @@ class DIALOG_ASSIGN_NETCLASS_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerStdButtonsCancel;
|
||||
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void onPatternText( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -39,15 +39,14 @@ public:
|
|||
~DIALOG_ASSIGN_NETCLASS() override {}
|
||||
|
||||
private:
|
||||
void OnUpdateUI( wxUpdateUIEvent &event ) override;
|
||||
|
||||
void onPatternText( wxCommandEvent& aEvent ) override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
private:
|
||||
EDA_BASE_FRAME* m_frame;
|
||||
std::set<wxString> m_netCandidates;
|
||||
|
||||
const std::function<void( const std::vector<wxString>& )>& m_previewer;
|
||||
std::function<void( const std::vector<wxString>& )> m_previewer;
|
||||
|
||||
wxString m_lastPattern;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue