json_settings.cpp: add more log traces on errors, when trying to save a json config.

pcb_calculator: fix a minor cosmetic issue: disabled wxStaticTexts are not very readable
on wxWidgets 3.1.4, so do not use disabled wxStaticTexts.
This commit is contained in:
jean-pierre charras 2020-08-23 15:01:52 +02:00
parent dd374e12ad
commit c80d029681
2 changed files with 15 additions and 12 deletions

View File

@ -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;
}

View File

@ -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;
}