diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 61e09faa6c..62049dbbc6 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -78,6 +78,7 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER ) EVT_ACTIVATE( EDA_DRAW_FRAME::onActivate ) END_EVENT_TABLE() +bool EDA_DRAW_FRAME::m_openGLFailureOccured = false; EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, @@ -92,7 +93,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_gridSelectBox = nullptr; m_zoomSelectBox = nullptr; m_searchPane = nullptr; - m_firstRunDialogSetting = 0; m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS; m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; @@ -319,14 +319,21 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars m_galDisplayOptions.ReadCommonConfig( *settings, this ); #ifndef __WXMAC__ - EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; - APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings(); + resolveCanvasType(); - if( cfg ) - canvasType = static_cast( cfg->m_Graphics.canvas_type ); + if( m_canvasType != GetCanvas()->GetBackend() ) + { + // Try to switch (will automatically fallback if necessary) + GetCanvas()->SwitchBackend( m_canvasType ); + EDA_DRAW_PANEL_GAL::GAL_TYPE newGAL = GetCanvas()->GetBackend(); + bool success = newGAL == m_canvasType; - if( canvasType != GetCanvas()->GetBackend() ) - GetCanvas()->SwitchBackend( canvasType ); + if( !success ) + { + m_canvasType = newGAL; + m_openGLFailureOccured = true; // Store failure for other EDA_DRAW_FRAMEs + } + } #endif // Notify all tools the preferences have changed @@ -666,7 +673,6 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) SetUserUnits( static_cast( aCfg->m_System.units ) ); m_undoRedoCountMax = aCfg->m_System.max_undo_items; - m_firstRunDialogSetting = aCfg->m_System.first_run_shown; m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this ); @@ -692,7 +698,6 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) WINDOW_SETTINGS* window = GetWindowSettings( aCfg ); aCfg->m_System.units = static_cast( GetUserUnits() ); - aCfg->m_System.first_run_shown = m_firstRunDialogSetting; aCfg->m_System.max_undo_items = GetMaxUndoItems(); m_galDisplayOptions.WriteConfig( *window ); @@ -1192,27 +1197,11 @@ void EDA_DRAW_FRAME::resolveCanvasType() { m_canvasType = loadCanvasTypeSetting(); - // Nudge user to switch to OpenGL if they are on legacy or Cairo - if( m_firstRunDialogSetting < 1 ) - { - if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) - { - // Save Cairo as default in case OpenGL crashes - saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); + // If we had an OpenGL failure this session, use the fallback GAL but don't update the + // user preference silently: - // Switch to OpenGL, which will save the new setting if successful - SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ); - - // Switch back to Cairo if OpenGL is not supported - if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) - SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); - - HardRedraw(); - } - - m_firstRunDialogSetting = 1; - SaveSettings( config() ); - } + if( m_openGLFailureOccured && m_canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) + m_canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; } diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index d6fbef7001..67b4ba5ae2 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -43,7 +43,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV m_appSettingsSchemaVersion( aSchemaVersion ) { // Make Coverity happy: - m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; + m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; // Build parameters list: m_params.emplace_back( @@ -68,7 +68,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV &m_FindReplace.replace_history, {} ) ); m_params.emplace_back( new PARAM( "graphics.canvas_type", - &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) ); + &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ); m_params.emplace_back( new PARAM( "graphics.highlight_factor", &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) ); @@ -130,7 +130,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV &m_Printing.layers, {} ) ); m_params.emplace_back( new PARAM( "system.first_run_shown", - &m_System.first_run_shown, false ) ); + &m_System.first_run_shown, false ) ); //@todo RFB remove? - not used m_params.emplace_back( new PARAM( "system.max_undo_items", &m_System.max_undo_items, 0 ) ); diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 1225ad0508..2f4d10301e 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -499,7 +499,6 @@ protected: bool m_polarCoords; // For those frames that support polar coordinates bool m_showBorderAndTitleBlock; // Show the drawing sheet (border & title block). - long m_firstRunDialogSetting; // Show first run dialog on startup wxChoice* m_gridSelectBox; wxChoice* m_zoomSelectBox; @@ -522,6 +521,9 @@ protected: ///< The current canvas type. EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType; + static bool m_openGLFailureOccured; ///< Has any failure occured when switching to OpenGL in + ///< any EDA_DRAW_FRAME? + private: BASE_SCREEN* m_currentScreen; ///< current used SCREEN EDA_DRAW_PANEL_GAL* m_canvas; diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index 3abef364fa..0b484ee588 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -153,7 +153,7 @@ public: struct SYSTEM { - bool first_run_shown; + bool first_run_shown; //@todo RFB remove? - not used int max_undo_items; std::vector file_history; int units;