From e4a6f2e5233374a126aa890b0901171ed5f74634 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 4 Jun 2018 11:49:53 +0200 Subject: [PATCH] Switch canvas to Cairo if OpenGL is not supported on the first run --- gerbview/gerbview_frame.cpp | 13 +++++++++---- pcbnew/pcb_edit_frame.cpp | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 9ce20c3000..3ddaf9320b 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -228,15 +228,20 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): // Switch to OpenGL, which will save the new setting if successful wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL ); - auto handler = GetEventHandler(); - handler->ProcessEvent( evt ); + GetEventHandler()->ProcessEvent( evt ); + + // Switch back to Cairo if OpenGL is not supported + if( GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) + { + wxCommandEvent cairoEvt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); + GetEventHandler()->ProcessEvent( cairoEvt ); + } } else if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) { // If they were on legacy, switch them to Cairo wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); - auto handler = GetEventHandler(); - handler->ProcessEvent( evt ); + GetEventHandler()->ProcessEvent( evt ); } } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index b9f1edd4b0..5f9e930c55 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -484,15 +484,20 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Switch to OpenGL, which will save the new setting if successful wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL ); - auto handler = GetEventHandler(); - handler->ProcessEvent( evt ); + GetEventHandler()->ProcessEvent( evt ); + + // Switch back to Cairo if OpenGL is not supported + if( GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) + { + wxCommandEvent cairoEvt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); + GetEventHandler()->ProcessEvent( cairoEvt ); + } } else if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) { // If they were on legacy, switch them to Cairo wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); - auto handler = GetEventHandler(); - handler->ProcessEvent( evt ); + GetEventHandler()->ProcessEvent( evt ); } }