diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 7ad15018e4..242fd8bdb7 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -42,6 +42,7 @@ #include #include #include +#include void LIB_EDIT_FRAME::LoadOneSymbol() @@ -151,14 +152,17 @@ void LIB_EDIT_FRAME::LoadOneSymbol() void LIB_EDIT_FRAME::SaveOneSymbol() { - wxString msg; - PROJECT& prj = Prj(); - SEARCH_STACK* search = prj.SchSearchS(); + // Export the current part as a symbol (.sym file) + // this is the current part without its aliases and doc file + // because a .sym file is used to import graphics in a part being edited LIB_PART* part = GetCurPart(); if( !part || part->GetDrawItems().empty() ) return; + PROJECT& prj = Prj(); + SEARCH_STACK* search = prj.SchSearchS(); + wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH ); if( !default_path ) @@ -181,14 +185,26 @@ void LIB_EDIT_FRAME::SaveOneSymbol() prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() ); - msg.Printf( _( "Saving symbol in '%s'" ), GetChars( fn.GetPath() ) ); + if( fn.FileExists() ) + { + wxRemove( fn.GetFullPath() ); + } + + wxString msg; + msg.Printf( _( "Saving symbol in '%s'" ), fn.GetPath() ); SetStatusText( msg ); SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); try { - pi->SaveSymbol( fn.GetFullPath(), part ); + PROPERTIES nodoc_props; // Doc file is useless for a .sym file + nodoc_props[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = ""; + pi->CreateSymbolLib( fn.GetFullPath(), &nodoc_props ); + + LIB_PART* saved_part = new LIB_PART( *part ); + saved_part->RemoveAllAliases(); // useless in a .sym file + pi->SaveSymbol( fn.GetFullPath(), saved_part, &nodoc_props ); } catch( const IO_ERROR& ioe ) {