Remove background fp loading from Choose Symbol dlg.

There are a bunch of problems with event processing and closing
documents, etc., when enabled.  See the bug report for more
info.

Fixes: lp:1774777
* https://bugs.launchpad.net/kicad/+bug/1774777
This commit is contained in:
Jeff Young 2018-06-09 00:50:06 +01:00
parent 5098c5796a
commit b9874da3a6
7 changed files with 41 additions and 55 deletions

View File

@ -603,6 +603,8 @@ int DIALOG_SHIM::ShowQuasiModal()
event_loop.Run(); event_loop.Run();
m_qmodal_showing = false;
return GetReturnCode(); return GetReturnCode();
} }
@ -622,8 +624,6 @@ void DIALOG_SHIM::EndQuasiModal( int retCode )
return; return;
} }
m_qmodal_showing = false;
if( m_qmodal_loop ) if( m_qmodal_loop )
{ {
if( m_qmodal_loop->IsRunning() ) if( m_qmodal_loop->IsRunning() )

View File

@ -20,19 +20,10 @@
#include <dialog_shim.h> #include <dialog_shim.h>
#include <kiway.h> #include <kiway.h>
#include <kiway_player.h> #include <kiway_player.h>
#include <make_unique.h>
#include <project.h> #include <project.h>
#include <widgets/footprint_choice.h> #include <widgets/footprint_choice.h>
#include <widgets/footprint_select_widget.h> #include <widgets/footprint_select_widget.h>
#include <functional>
#include <wx/combo.h>
#include <wx/gauge.h>
#include <wx/odcombo.h>
#include <wx/simplebook.h>
#include <wx/sizer.h>
#include <wx/timer.h>
#include <wx/utils.h>
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
#include <widgets/progress_reporter.h> #include <widgets/progress_reporter.h>
@ -47,16 +38,6 @@ enum
}; };
/**
* Page numbers in the wxSimplebook
*/
enum
{
PAGE_PROGRESS,
PAGE_SELECT
};
wxDEFINE_EVENT( EVT_FOOTPRINT_SELECTED, wxCommandEvent ); wxDEFINE_EVENT( EVT_FOOTPRINT_SELECTED, wxCommandEvent );
@ -73,22 +54,15 @@ FOOTPRINT_SELECT_WIDGET::FOOTPRINT_SELECT_WIDGET( wxWindow* aParent,
{ {
m_zero_filter = true; m_zero_filter = true;
m_sizer = new wxBoxSizer( wxVERTICAL ); m_sizer = new wxBoxSizer( wxVERTICAL );
m_book = new wxSimplebook( this, wxID_ANY ); m_fp_sel_ctrl = new FOOTPRINT_CHOICE( this, wxID_ANY );
m_progress_ctrl = new GAUGE_PROGRESS_REPORTER( m_book, 2 ); m_sizer->Add( m_fp_sel_ctrl, 1, wxEXPAND | wxALL, 5 );
m_fp_sel_ctrl = new FOOTPRINT_CHOICE( m_book, wxID_ANY );
m_book->SetEffect( wxSHOW_EFFECT_BLEND );
m_book->AddPage( m_progress_ctrl, "", true );
m_book->AddPage( m_fp_sel_ctrl, "", false );
m_sizer->Add( m_book, 1, wxEXPAND | wxALL, 5 );
SetSizer( m_sizer ); SetSizer( m_sizer );
Layout(); Layout();
m_sizer->Fit( this ); m_sizer->Fit( this );
m_fp_sel_ctrl->Bind( wxEVT_COMBOBOX, &FOOTPRINT_SELECT_WIDGET::OnComboBox, this ); m_fp_sel_ctrl->Bind( wxEVT_COMBOBOX, &FOOTPRINT_SELECT_WIDGET::OnComboBox, this );
m_fp_sel_ctrl->Bind( m_fp_sel_ctrl->Bind( EVT_INTERACTIVE_CHOICE, &FOOTPRINT_SELECT_WIDGET::OnComboInteractive, this );
EVT_INTERACTIVE_CHOICE, &FOOTPRINT_SELECT_WIDGET::OnComboInteractive, this );
} }
@ -101,7 +75,8 @@ void FOOTPRINT_SELECT_WIDGET::Load( KIWAY& aKiway, PROJECT& aProject )
auto fp_lib_table = aProject.PcbFootprintLibs( aKiway ); auto fp_lib_table = aProject.PcbFootprintLibs( aKiway );
m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway ); m_fp_list = FOOTPRINT_LIST::GetInstance( aKiway );
m_fp_list->ReadFootprintFiles( fp_lib_table, nullptr, m_progress_ctrl ); WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
m_fp_list->ReadFootprintFiles( fp_lib_table, nullptr, &progressReporter );
FootprintsLoaded(); FootprintsLoaded();
} }
catch( ... ) catch( ... )
@ -115,7 +90,6 @@ void FOOTPRINT_SELECT_WIDGET::FootprintsLoaded()
{ {
m_fp_filter.SetList( *m_fp_list ); m_fp_filter.SetList( *m_fp_list );
m_book->SetSelection( PAGE_SELECT );
m_finished_loading = true; m_finished_loading = true;
if( m_update ) if( m_update )

View File

@ -62,7 +62,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ), m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
m_allow_field_edits( aAllowFieldEdits ), m_allow_field_edits( aAllowFieldEdits ),
m_show_footprints( aShowFootprints ), m_show_footprints( aShowFootprints ),
m_load_footprints( aShowFootprints ),
m_external_browser_requested( false ) m_external_browser_requested( false )
{ {
auto sizer = new wxBoxSizer( wxVERTICAL ); auto sizer = new wxBoxSizer( wxVERTICAL );
@ -101,7 +100,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
SetSizer( sizer ); SetSizer( sizer );
Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this ); Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
Bind( wxEVT_IDLE, &DIALOG_CHOOSE_COMPONENT::OnIdle, this ); Bind( wxEVT_ACTIVATE, &DIALOG_CHOOSE_COMPONENT::OnActivate, this );
Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() ); Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this ); Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this ); Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
@ -138,11 +137,21 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
DIALOG_CHOOSE_COMPONENT::~DIALOG_CHOOSE_COMPONENT() DIALOG_CHOOSE_COMPONENT::~DIALOG_CHOOSE_COMPONENT()
{ {
Unbind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
Unbind( wxEVT_ACTIVATE, &DIALOG_CHOOSE_COMPONENT::OnActivate, this );
Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
Unbind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
Unbind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
m_sch_view_ctrl->Unbind( wxEVT_LEFT_DCLICK, &DIALOG_CHOOSE_COMPONENT::OnSchViewDClick, this );
m_sch_view_ctrl->Unbind( wxEVT_PAINT, &DIALOG_CHOOSE_COMPONENT::OnSchViewPaint, this );
if( m_fp_sel_ctrl )
m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
// I am not sure the following two lines are necessary, // I am not sure the following two lines are necessary,
// but they will not hurt anyone // but they will not hurt anyone
m_dbl_click_timer->Stop(); m_dbl_click_timer->Stop();
Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
delete m_dbl_click_timer; delete m_dbl_click_timer;
m_last_dlg_size = GetSize(); m_last_dlg_size = GetSize();
@ -197,17 +206,17 @@ void DIALOG_CHOOSE_COMPONENT::OnInitDialog( wxInitDialogEvent& aEvent )
// This hides the GAL panel and shows the status label // This hides the GAL panel and shows the status label
m_fp_view_ctrl->SetStatusText( wxEmptyString ); m_fp_view_ctrl->SetStatusText( wxEmptyString );
} }
if( m_fp_sel_ctrl )
m_fp_sel_ctrl->Load( Kiway(), Prj() );
} }
// Let the dialog display before starting the footprint load void DIALOG_CHOOSE_COMPONENT::OnActivate( wxActivateEvent& event )
void DIALOG_CHOOSE_COMPONENT::OnIdle( wxIdleEvent& aEvent )
{ {
if( m_load_footprints && m_fp_sel_ctrl ) m_tree->SetFocus();
{
m_load_footprints = false; event.Skip(); // required under wxMAC
m_fp_sel_ctrl->Load( Kiway(), Prj() );
}
} }
@ -220,7 +229,7 @@ LIB_ID DIALOG_CHOOSE_COMPONENT::GetSelectedLibId( int* aUnit ) const
void DIALOG_CHOOSE_COMPONENT::OnCloseTimer( wxTimerEvent& aEvent ) void DIALOG_CHOOSE_COMPONENT::OnCloseTimer( wxTimerEvent& aEvent )
{ {
// Hack handler because of eaten MouseUp event. See // Hack handler because of eaten MouseUp event. See
// DIALOG_CHOOSE_COMPONENT::OnDoubleClickTreeActivation for the beginning // DIALOG_CHOOSE_COMPONENT::OnComponentSelected for the beginning
// of this spaghetti noodle. // of this spaghetti noodle.
auto state = wxGetMouseState(); auto state = wxGetMouseState();
@ -279,7 +288,7 @@ void DIALOG_CHOOSE_COMPONENT::ShowFootprintFor( LIB_ID const& aLibId )
void DIALOG_CHOOSE_COMPONENT::ShowFootprint( wxString const& aName ) void DIALOG_CHOOSE_COMPONENT::ShowFootprint( wxString const& aName )
{ {
if( !m_fp_view_ctrl ) if( !m_fp_view_ctrl || !m_fp_view_ctrl->IsInitialized() )
{ {
return; return;
} }

View File

@ -148,8 +148,8 @@ protected:
wxPanel* ConstructRightPanel( wxWindow* aParent ); wxPanel* ConstructRightPanel( wxWindow* aParent );
void OnInitDialog( wxInitDialogEvent& aEvent ); void OnInitDialog( wxInitDialogEvent& aEvent );
void OnActivate( wxActivateEvent& event );
void OnCloseTimer( wxTimerEvent& aEvent ); void OnCloseTimer( wxTimerEvent& aEvent );
void OnIdle( wxIdleEvent& aEvent );
void OnSchViewDClick( wxMouseEvent& aEvent ); void OnSchViewDClick( wxMouseEvent& aEvent );
void OnSchViewPaint( wxPaintEvent& aEvent ); void OnSchViewPaint( wxPaintEvent& aEvent );
@ -207,7 +207,6 @@ protected:
int m_deMorganConvert; int m_deMorganConvert;
bool m_allow_field_edits; bool m_allow_field_edits;
bool m_show_footprints; bool m_show_footprints;
bool m_load_footprints;
bool m_external_browser_requested; bool m_external_browser_requested;
wxString m_fp_override; wxString m_fp_override;

View File

@ -182,6 +182,15 @@ void COMPONENT_TREE::Regenerate()
} }
void COMPONENT_TREE::SetFocus()
{
if( m_query_ctrl )
m_query_ctrl->SetFocus();
else
m_tree_ctrl->SetFocus();
}
void COMPONENT_TREE::toggleExpand( const wxDataViewItem& aTreeId ) void COMPONENT_TREE::toggleExpand( const wxDataViewItem& aTreeId )
{ {
if( !aTreeId.IsOk() ) if( !aTreeId.IsOk() )

View File

@ -106,6 +106,8 @@ public:
*/ */
void Regenerate(); void Regenerate();
void SetFocus() override;
protected: protected:
/** /**
* Expands or collapses a node, switching it to the opposite state. * Expands or collapses a node, switching it to the opposite state.

View File

@ -29,12 +29,7 @@
class KIWAY; class KIWAY;
class PROJECT; class PROJECT;
class FOOTPRINT_CHOICE; class FOOTPRINT_CHOICE;
class GAUGE_PROGRESS_REPORTER;
class wxMenu;
class wxTimer;
class wxTimerEvent;
class wxWindow; class wxWindow;
class wxSimplebook;
/** /**
* This event is fired when a footprint is selected. The string data of the * This event is fired when a footprint is selected. The string data of the
@ -130,10 +125,8 @@ public:
private: private:
KIWAY* m_kiway; KIWAY* m_kiway;
GAUGE_PROGRESS_REPORTER* m_progress_ctrl;
FOOTPRINT_CHOICE* m_fp_sel_ctrl; FOOTPRINT_CHOICE* m_fp_sel_ctrl;
wxSizer* m_sizer; wxSizer* m_sizer;
wxSimplebook* m_book;
bool m_update; bool m_update;
bool m_finished_loading; bool m_finished_loading;