Eeschema: Catch error on init

Some windows systems will not fall back correctly on our standard
initialization step, so we need the additional std:: error fall back to
catch them.

Fixes #2620 | https://gitlab.com/kicad/code/kicad/issues/2620
This commit is contained in:
Seth Hillbrand 2019-12-10 07:47:13 -08:00
parent 9b7d4e2742
commit e39586e157
2 changed files with 44 additions and 11 deletions

View File

@ -24,19 +24,28 @@
*/
#include <view/wx_view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <sch_draw_panel.h>
#include <sch_view.h>
#include <wx/debug.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/window.h>
#include <wx/windowid.h>
#include <memory>
#include <stdexcept>
#include <confirm.h>
#include <eda_draw_frame.h>
#include <gal/definitions.h>
#include <gal/graphics_abstraction_layer.h>
#include <layers_id_colors_and_visibility.h>
#include <math/vector2d.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <view/wx_view_controls.h>
#include <sch_base_frame.h>
#include <sch_painter.h>
#include <sch_edit_frame.h>
#include <preview_items/selection_area.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <functional>
#include <sch_sheet.h>
#include <pgm_base.h>
#include <tools/ee_selection_tool.h>
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<SCH_BASE_FRAME*>( 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

View File

@ -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.