From d4bb1cbc63a0ba7cc1eb74f68de2658fcb0fd6ea Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 1 May 2021 14:11:16 -0400 Subject: [PATCH] Make drawing sheet loading slightly smarter --- common/dialogs/dialog_page_settings.cpp | 19 +++++++++++++------ eeschema/eeschema_config.cpp | 5 ++++- pcbnew/pcbnew_config.cpp | 5 ++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index dc0bcb3626..2e8fd0e86d 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -806,13 +806,20 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event ) shortFileName = fileName; } - SetWksFileName( shortFileName ); + DS_DATA_MODEL* ws = new DS_DATA_MODEL; - if( m_drawingSheet == NULL ) - m_drawingSheet = new DS_DATA_MODEL; + if( ws->LoadDrawingSheet( fileName ) ) + { + if( m_drawingSheet != nullptr ) + { + delete m_drawingSheet; + } - m_drawingSheet->LoadDrawingSheet( fileName ); + m_drawingSheet = ws; - GetPageLayoutInfoFromDialog(); - UpdatePageLayoutExample(); + SetWksFileName( shortFileName ); + + GetPageLayoutInfoFromDialog(); + UpdatePageLayoutExample(); + } } diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 4378bba585..6f307e88d2 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -94,7 +94,10 @@ bool SCH_EDIT_FRAME::LoadProjectSettings() wxString filename = DS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName, Prj().GetProjectPath() ); - DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ); + if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) ) + { + ShowInfoBarError( _( "Error loading drawing sheet" ), true ); + } return true; } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 850034dd54..383f37b747 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -77,7 +77,10 @@ bool PCB_EDIT_FRAME::LoadProjectSettings() wxString filename = DS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName, Prj().GetProjectPath() ); - DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ); + if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) ) + { + ShowInfoBarError( _( "Error loading drawing sheet" ), true ); + } // Load render settings that aren't stored in PCB_DISPLAY_OPTIONS