diff --git a/common/widgets/design_block_preview_widget.h b/common/widgets/design_block_preview_widget.h index 46b2e52141..66c1e0c284 100644 --- a/common/widgets/design_block_preview_widget.h +++ b/common/widgets/design_block_preview_widget.h @@ -45,6 +45,11 @@ public: DESIGN_BLOCK_PREVIEW_WIDGET( wxWindow* aParent ) : wxPanel( aParent ) {} ~DESIGN_BLOCK_PREVIEW_WIDGET() = default; + /** + * Return whether the widget initialized properly. This could return false if Kiway is + * not available. If this returns false, no other methods should be called. + */ + virtual bool IsInitialized() const = 0; /** * Set the contents of the status label and display it. diff --git a/common/widgets/panel_design_block_chooser.cpp b/common/widgets/panel_design_block_chooser.cpp index e3e65b9435..bb465b52bd 100644 --- a/common/widgets/panel_design_block_chooser.cpp +++ b/common/widgets/panel_design_block_chooser.cpp @@ -318,6 +318,9 @@ void PANEL_DESIGN_BLOCK_CHOOSER::onOpenLibsTimer( wxTimerEvent& aEvent ) void PANEL_DESIGN_BLOCK_CHOOSER::onDesignBlockSelected( wxCommandEvent& aEvent ) { + if( !m_preview || !m_preview->IsInitialized() ) + return; + if( GetSelectedLibId().IsValid() ) { std::unique_ptr designBlock( m_parent->GetDesignBlock( GetSelectedLibId(), true, true ) ); diff --git a/eeschema/widgets/sch_design_block_preview_widget.h b/eeschema/widgets/sch_design_block_preview_widget.h index 0b20600dc4..06dddd6324 100644 --- a/eeschema/widgets/sch_design_block_preview_widget.h +++ b/eeschema/widgets/sch_design_block_preview_widget.h @@ -47,6 +47,12 @@ public: ~SCH_DESIGN_BLOCK_PREVIEW_WIDGET() override; + /* + * Return whether the widget initialized properly. This could return false if Kiway is + * not available. If this returns false, no other methods should be called. + */ + bool IsInitialized() const override { return m_preview != nullptr; } + /** * Set the contents of the status label and display it. */ diff --git a/pcbnew/widgets/pcb_design_block_preview_widget.h b/pcbnew/widgets/pcb_design_block_preview_widget.h index 7a80ec3e7e..bff9e619bf 100644 --- a/pcbnew/widgets/pcb_design_block_preview_widget.h +++ b/pcbnew/widgets/pcb_design_block_preview_widget.h @@ -47,6 +47,12 @@ public: ~PCB_DESIGN_BLOCK_PREVIEW_WIDGET() override; + /** + * Return whether the widget initialized properly. This could return false if Kiway is + * not available. If this returns false, no other methods should be called. + */ + bool IsInitialized() const override { return m_preview != nullptr; } + /** * Set the contents of the status label and display it. */