Move cvpcb filter to a timer.
Fixes https://gitlab.com/kicad/code/kicad/issues/12445
This commit is contained in:
parent
64a6fc0fd4
commit
1fcd7d6285
|
@ -67,7 +67,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
|
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
|
||||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME,
|
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME,
|
||||||
unityScale ),
|
unityScale ),
|
||||||
m_footprintListPendingUpdate( false ),
|
|
||||||
m_viewerPendingUpdate( false )
|
m_viewerPendingUpdate( false )
|
||||||
{
|
{
|
||||||
m_symbolsListBox = nullptr;
|
m_symbolsListBox = nullptr;
|
||||||
|
@ -220,12 +219,17 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
// Start the main processing loop
|
// Start the main processing loop
|
||||||
m_toolManager->InvokeTool( "cvpcb.Control" );
|
m_toolManager->InvokeTool( "cvpcb.Control" );
|
||||||
|
|
||||||
|
m_filterTimer->StartOnce( 100 );
|
||||||
|
|
||||||
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
||||||
{
|
{
|
||||||
|
// Stop the timer during destruction early to avoid potential race conditions (that do happen)
|
||||||
|
m_filterTimer->Stop();
|
||||||
|
|
||||||
// Shutdown all running tools
|
// Shutdown all running tools
|
||||||
if( m_toolManager )
|
if( m_toolManager )
|
||||||
m_toolManager->ShutdownAllTools();
|
m_toolManager->ShutdownAllTools();
|
||||||
|
@ -381,6 +385,9 @@ void CVPCB_MAINFRAME::setupEventHandlers()
|
||||||
// Attach the events to the tool dispatcher
|
// Attach the events to the tool dispatcher
|
||||||
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
||||||
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
||||||
|
|
||||||
|
m_filterTimer = new wxTimer( this );
|
||||||
|
Bind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,19 +438,12 @@ void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
|
||||||
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
|
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
|
||||||
// of available footprints which match the filter
|
// of available footprints which match the filter
|
||||||
|
|
||||||
if( !m_footprintListPendingUpdate )
|
m_filterTimer->StartOnce( 200 );
|
||||||
{
|
|
||||||
Bind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintListOnIdle, this );
|
|
||||||
m_footprintListPendingUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CVPCB_MAINFRAME::updateFootprintListOnIdle( wxIdleEvent& aEvent )
|
void CVPCB_MAINFRAME::onTextFilterChangedTimer( wxTimerEvent& aEvent )
|
||||||
{
|
{
|
||||||
Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintListOnIdle, this );
|
|
||||||
m_footprintListPendingUpdate = false;
|
|
||||||
|
|
||||||
// GTK loses the search-control's focus on a Refresh event, so we record the focus and
|
// GTK loses the search-control's focus on a Refresh event, so we record the focus and
|
||||||
// insertion point here and then restore them at the end.
|
// insertion point here and then restore them at the end.
|
||||||
bool searchCtrlHasFocus = m_tcFilterString->HasFocus();
|
bool searchCtrlHasFocus = m_tcFilterString->HasFocus();
|
||||||
|
|
|
@ -345,7 +345,7 @@ private:
|
||||||
|
|
||||||
void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
|
void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
|
||||||
|
|
||||||
void updateFootprintListOnIdle( wxIdleEvent& aEvent );
|
void onTextFilterChangedTimer( wxTimerEvent& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the .equ files and populate the list of equivalents.
|
* Read the .equ files and populate the list of equivalents.
|
||||||
|
@ -396,7 +396,7 @@ private:
|
||||||
CVPCB_UNDO_REDO_LIST m_undoList;
|
CVPCB_UNDO_REDO_LIST m_undoList;
|
||||||
CVPCB_UNDO_REDO_LIST m_redoList;
|
CVPCB_UNDO_REDO_LIST m_redoList;
|
||||||
|
|
||||||
bool m_footprintListPendingUpdate;
|
wxTimer* m_filterTimer;
|
||||||
bool m_viewerPendingUpdate;
|
bool m_viewerPendingUpdate;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue