diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index b4e98f0266..bf73f781ec 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -242,8 +242,8 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory ) } catch( nlohmann::json::parse_error& error ) { - wxLogTrace( - traceSettings, "Parse error reading %s: %s", path.GetFullPath(), error.what() ); + wxLogTrace( traceSettings, "Json parse error reading %s: %s", + path.GetFullPath(), error.what() ); wxLogTrace( traceSettings, "Attempting migration in case file is in legacy format" ); migrateFromLegacy( path ); } @@ -263,8 +263,8 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory ) { if( legacy_migrated && m_deleteLegacyAfterMigration && !wxRemoveFile( path.GetFullPath() ) ) { - wxLogTrace( - traceSettings, "Warning: could not remove legacy file %s", path.GetFullPath() ); + wxLogTrace( traceSettings, "Warning: could not remove legacy file %s", + path.GetFullPath() ); } // And write-out immediately so that we don't lose data if the program later crashes. @@ -367,19 +367,26 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce ) try { - wxFile file( path.GetFullPath(), wxFile::write ); - std::stringstream buffer; buffer << std::setw( 2 ) << *this << std::endl; + wxFile file( path.GetFullPath(), wxFile::write ); + if( !file.IsOpened() || !file.Write( buffer.str().c_str(), buffer.str().size() ) ) { wxLogTrace( traceSettings, "Warning: could not save %s", GetFullFilename() ); success = false; } } + catch( nlohmann::json::exception& error ) + { + wxLogTrace( traceSettings, "Catch error: could not save %s. Json error %s", + GetFullFilename(), error.what() ); + success = false; + } catch( ... ) { + wxLogTrace( traceSettings, "Error: could not save %s." ); success = false; } diff --git a/pcb_calculator/regulators_funct.cpp b/pcb_calculator/regulators_funct.cpp index 3642462709..f35d1a8042 100644 --- a/pcb_calculator/regulators_funct.cpp +++ b/pcb_calculator/regulators_funct.cpp @@ -79,8 +79,6 @@ public: { bool enbl = m_choiceRegType->GetSelection() == 1; m_RegulIadjValue->Enable( enbl ); - m_RegulIadjTitle->Enable( enbl ); - m_IadjUnitLabel->Enable( enbl ); } /** @@ -144,8 +142,10 @@ REGULATOR_DATA * DIALOG_EDITOR_DATA::BuildRegulatorFromData() double vref = DoubleFromString( m_textCtrlVref->GetValue() ); double iadj = DoubleFromString( m_RegulIadjValue->GetValue() ); int type = m_choiceRegType->GetSelection(); + if( type != 1 ) iadj = 0.0; + REGULATOR_DATA * item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vref, type, iadj ); return item; @@ -178,8 +178,6 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() m_bitmapRegul4pins->Show( true ); m_bitmapRegul3pins->Show( false ); m_RegulIadjValue->Enable( false ); - m_RegulIadjTitle->Enable( false ); - m_IadjUnitLabel->Enable( false ); m_RegulFormula->SetLabel( wxT("Vout = Vref * (R1 + R2) / R2") ); break; @@ -187,8 +185,6 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() m_bitmapRegul4pins->Show( false ); m_bitmapRegul3pins->Show( true ); m_RegulIadjValue->Enable( true ); - m_RegulIadjTitle->Enable( true ); - m_IadjUnitLabel->Enable( true ); m_RegulFormula->SetLabel( wxT("Vout = Vref * (R1 + R2) / R1 + Iadj * R2") ); break; }