Export drawing in symbol editor results in error message and no drawing file (.sym file) saved

Fixes: lp:1737875
https://bugs.launchpad.net/kicad/+bug/1737875
This commit is contained in:
jean-pierre charras 2017-12-14 16:45:30 +01:00
parent a287748921
commit dc6c98310f
1 changed files with 21 additions and 5 deletions

View File

@ -42,6 +42,7 @@
#include <class_libentry.h>
#include <wildcards_and_files_ext.h>
#include <sch_legacy_plugin.h>
#include <properties.h>
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 )
{