Fix wierd ConfigBaseWriteDouble's Printf( wxT("%12f"), aValue ); format string

which was creating silly strings like 

  PcbTextThickness="    0.300000"

in kicad.pro files.
This commit is contained in:
Dick Hollenbeck 2013-06-04 09:44:21 -05:00
parent 94338e072f
commit 3bddb98de9
2 changed files with 17 additions and 19 deletions

View File

@ -19,8 +19,20 @@
#include <boost/foreach.hpp>
#define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true
#define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true
void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue )
{
// Use a single strategy, regardless of wx version.
// Want C locale float string.
LOCALE_IO toggle;
wxString tnumber = wxString::Format( wxT( "%.16g" ), aValue );
aConfig->Write( aKey, tnumber );
}
bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,

View File

@ -15,28 +15,14 @@
/**
* inline ConfigBaseWriteDouble
* This is a helper funvtion tor write doubles in config
* Function ConfigBaseWriteDouble
* This is a helper function to write doubles in config
* We cannot use wxConfigBase->Write for a double, because
* this function uses a format with very few digits in mantissa,
* and truncation issues are frequent.
* We use here a better floating format.
*
* Note: prior to 2.9.1, the separator was localized, and after, uses
* the "C" notation
*/
void inline ConfigBaseWriteDouble( wxConfigBase* aConfig,
const wxString& aKey, double aValue )
{
wxString tnumber;
#if wxCHECK_VERSION(2,9,1)
tnumber = wxString::FromCDouble( aValue, 12 );
#else
tnumber.Printf( wxT("%12f"), aValue );
#endif
aConfig->Write( aKey, tnumber );
}
void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue );
/** Type of parameter in the configuration file */