diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 83c9a6cdf1..ce987d6aa4 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -24,19 +24,28 @@ */ -#include -#include #include -#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include -#include -#include -#include -#include -#include -#include -#include -#include SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, @@ -167,6 +176,27 @@ KIGFX::SCH_VIEW* SCH_DRAW_PANEL::GetView() const } +void SCH_DRAW_PANEL::OnShow() +{ + SCH_BASE_FRAME* frame = dynamic_cast( GetParent() ); + + try + { + // Check if the current rendering backend can be properly initialized + m_view->UpdateItems(); + } + catch( const std::runtime_error& e ) + { + // Fallback to software renderer + DisplayInfoMessage( frame, e.what() ); + SwitchBackend( GAL_TYPE_CAIRO ); + + if( frame ) + frame->ActivateGalCanvas(); + } +} + + void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) { // The first wxPaintEvent can be fired at startup before the GAL engine is fully initialized diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index b4fb00893f..e5a993870d 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -54,6 +54,9 @@ public: protected: virtual void onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) override; + ///> @copydoc EDA_DRAW_PANEL_GAL::OnShow() + void OnShow() override; + void setDefaultLayerOrder(); ///> Reassigns layer order to the initial settings. void setDefaultLayerDeps(); ///> Sets rendering targets & dependencies for layers.