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:
parent
a287748921
commit
dc6c98310f
|
@ -42,6 +42,7 @@
|
||||||
#include <class_libentry.h>
|
#include <class_libentry.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <sch_legacy_plugin.h>
|
#include <sch_legacy_plugin.h>
|
||||||
|
#include <properties.h>
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::LoadOneSymbol()
|
void LIB_EDIT_FRAME::LoadOneSymbol()
|
||||||
|
@ -151,14 +152,17 @@ void LIB_EDIT_FRAME::LoadOneSymbol()
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::SaveOneSymbol()
|
void LIB_EDIT_FRAME::SaveOneSymbol()
|
||||||
{
|
{
|
||||||
wxString msg;
|
// Export the current part as a symbol (.sym file)
|
||||||
PROJECT& prj = Prj();
|
// this is the current part without its aliases and doc file
|
||||||
SEARCH_STACK* search = prj.SchSearchS();
|
// because a .sym file is used to import graphics in a part being edited
|
||||||
LIB_PART* part = GetCurPart();
|
LIB_PART* part = GetCurPart();
|
||||||
|
|
||||||
if( !part || part->GetDrawItems().empty() )
|
if( !part || part->GetDrawItems().empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PROJECT& prj = Prj();
|
||||||
|
SEARCH_STACK* search = prj.SchSearchS();
|
||||||
|
|
||||||
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
||||||
|
|
||||||
if( !default_path )
|
if( !default_path )
|
||||||
|
@ -181,14 +185,26 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
|
||||||
|
|
||||||
prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
|
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 );
|
SetStatusText( msg );
|
||||||
|
|
||||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
|
||||||
|
|
||||||
try
|
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 )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue