Fix some UTF8 issues with project settings
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4808
This commit is contained in:
parent
e76d302197
commit
6eca886292
|
@ -153,7 +153,8 @@ bool JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
|
|||
}
|
||||
else
|
||||
{
|
||||
path.Assign( aDirectory, m_filename, getFileExt() );
|
||||
wxString dir( aDirectory.c_str(), wxConvUTF8 );
|
||||
path.Assign( dir, m_filename, getFileExt() );
|
||||
}
|
||||
|
||||
if( !path.Exists() )
|
||||
|
@ -182,7 +183,7 @@ bool JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
|
|||
{
|
||||
try
|
||||
{
|
||||
std::ifstream in( path.GetFullPath().ToStdString() );
|
||||
std::ifstream in( path.GetFullPath().ToUTF8() );
|
||||
in >> *this;
|
||||
|
||||
// If parse succeeds, check if schema migration is required
|
||||
|
@ -294,7 +295,8 @@ bool JSON_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce )
|
|||
}
|
||||
else
|
||||
{
|
||||
path.Assign( aDirectory, m_filename, getFileExt() );
|
||||
wxString dir( aDirectory.c_str(), wxConvUTF8 );
|
||||
path.Assign( dir, m_filename, getFileExt() );
|
||||
}
|
||||
|
||||
if( !m_createIfMissing && !path.FileExists() )
|
||||
|
@ -338,7 +340,7 @@ bool JSON_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce )
|
|||
|
||||
try
|
||||
{
|
||||
std::ofstream file( path.GetFullPath().ToStdString() );
|
||||
std::ofstream file( path.GetFullPath().ToUTF8() );
|
||||
file << std::setw( 2 ) << *this << std::endl;
|
||||
}
|
||||
catch( const std::exception& e )
|
||||
|
@ -551,4 +553,4 @@ void to_json( nlohmann::json& aJson, const wxString& aString )
|
|||
void from_json( const nlohmann::json& aJson, wxString& aString )
|
||||
{
|
||||
aString = wxString( aJson.get<std::string>().c_str(), wxConvUTF8 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -706,7 +706,7 @@ bool SETTINGS_MANAGER::LoadProject( const wxString& aFullPath, bool aSetActive )
|
|||
|
||||
m_projects[fullPath].reset( project.release() );
|
||||
|
||||
std::string fn( path.GetName() );
|
||||
std::string fn( path.GetName().ToUTF8() );
|
||||
|
||||
PROJECT_LOCAL_SETTINGS* settings = static_cast<PROJECT_LOCAL_SETTINGS*>(
|
||||
RegisterSettings( new PROJECT_LOCAL_SETTINGS( fn ) ) );
|
||||
|
@ -783,7 +783,9 @@ bool SETTINGS_MANAGER::loadProjectFile( PROJECT& aProject )
|
|||
aProject.setProjectFile( file );
|
||||
file->SetProject( &aProject );
|
||||
|
||||
return file->LoadFromFile( std::string( fullFn.GetPath().ToUTF8() ) );
|
||||
std::string path( fullFn.GetPath().ToUTF8() );
|
||||
|
||||
return file->LoadFromFile( path );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,11 @@ protected:
|
|||
return ProjectLocalSettingsFileExtension;
|
||||
}
|
||||
|
||||
wxString getLegacyFileExt() const override
|
||||
{
|
||||
return wxT( "NO_SUCH_FILE_EXTENSION" );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// A link to the owning project
|
||||
|
|
|
@ -94,6 +94,9 @@ int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeIte
|
|||
TREEPROJECT_ITEM* myitem1 = (TREEPROJECT_ITEM*) GetItemData( item1 );
|
||||
TREEPROJECT_ITEM* myitem2 = (TREEPROJECT_ITEM*) GetItemData( item2 );
|
||||
|
||||
if( !myitem1 || !myitem2 )
|
||||
return 0;
|
||||
|
||||
if( myitem1->GetType() == TREE_DIRECTORY && myitem2->GetType() != TREE_DIRECTORY )
|
||||
return -1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue