Commit 84572d37 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix bug I recently created: footprint lib incorrectly saved (first module can be lost)

parent 87e220e1
...@@ -283,6 +283,7 @@ static void OuputHeader( BITMAPCONV_INFO& aInfo ) ...@@ -283,6 +283,7 @@ static void OuputHeader( BITMAPCONV_INFO& aInfo )
aInfo.m_PixmapWidth, aInfo.m_PixmapHeight ); aInfo.m_PixmapWidth, aInfo.m_PixmapHeight );
fprintf( aInfo.m_Outfile, "$MODULE %s\n", CmpName ); fprintf( aInfo.m_Outfile, "$MODULE %s\n", CmpName );
fprintf( aInfo.m_Outfile, "Po 0 0 0 15 00000000 00000000 ~~\n"); fprintf( aInfo.m_Outfile, "Po 0 0 0 15 00000000 00000000 ~~\n");
fprintf( aInfo.m_Outfile, "Li %s\n", CmpName );
fprintf( aInfo.m_Outfile, "T0 0 %d %d %d 0 %d N I %d \"G***\"\n", fprintf( aInfo.m_Outfile, "T0 0 %d %d %d 0 %d N I %d \"G***\"\n",
Ypos, fieldSize, fieldSize, fieldSize/5, FIELD_LAYER ); Ypos, fieldSize, fieldSize, fieldSize/5, FIELD_LAYER );
fprintf( aInfo.m_Outfile, "T1 0 %d %d %d 0 %d N I %d \"%s\"\n", fprintf( aInfo.m_Outfile, "T1 0 %d %d %d 0 %d N I %d \"%s\"\n",
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#endif #endif
#ifndef KICAD_BUILD_VERSION #ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-07-07)" #define KICAD_BUILD_VERSION "(2011-07-08)"
#endif #endif
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
; General Product Description Definitions ; General Product Description Definitions
!define PRODUCT_NAME "KiCad" !define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.07.07" !define PRODUCT_VERSION "2011.07.08"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/" !define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME "" !define COMPANY_NAME ""
......
...@@ -364,7 +364,6 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname ...@@ -364,7 +364,6 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOnly ) void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOnly )
{ {
int ii, NbModules = 0; int ii, NbModules = 0;
float Pas;
MODULE* Module; MODULE* Module;
wxString fileName = LibName, path; wxString fileName = LibName, path;
...@@ -424,7 +423,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -424,7 +423,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; Module != NULL; Module = (MODULE*) Module->Next() )
NbModules++; NbModules++;
Pas = (float) 100 / NbModules; double step = 100.0 / NbModules;
DisplayActivity( 0, wxEmptyString ); DisplayActivity( 0, wxEmptyString );
Module = (MODULE*) GetBoard()->m_Modules; Module = (MODULE*) GetBoard()->m_Modules;
...@@ -434,7 +433,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -434,7 +433,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
NewModulesOnly ? false : true, NewModulesOnly ? false : true,
false ) == 0 ) false ) == 0 )
break; break;
DisplayActivity( (int) ( ii * Pas ), wxEmptyString ); DisplayActivity( (int) ( ii * step ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */ /* Check for request to stop backup (ESCAPE key actuated) */
if( DrawPanel->m_AbortRequest ) if( DrawPanel->m_AbortRequest )
break; break;
...@@ -485,12 +484,19 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, ...@@ -485,12 +484,19 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
{ {
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp ); wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return 0; // cancelled by user return false; // cancelled by user
Name_Cmp = dlg.GetValue(); Name_Cmp = dlg.GetValue();
Name_Cmp.Trim( true ); Name_Cmp.Trim( true );
Name_Cmp.Trim( false ); Name_Cmp.Trim( false );
if( Name_Cmp.IsEmpty() ) if( Name_Cmp.IsEmpty() )
return 0; return false;
aModule->m_LibRef = Name_Cmp;
}
// Ensure this footprint has a libname
if( Name_Cmp.IsEmpty() )
{
Name_Cmp = wxT("noname");
aModule->m_LibRef = Name_Cmp; aModule->m_LibRef = Name_Cmp;
} }
...@@ -528,7 +534,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, ...@@ -528,7 +534,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
if( !aOverwrite ) // Do not save the given footprint: an old one exists if( !aOverwrite ) // Do not save the given footprint: an old one exists
{ {
fclose( lib_module ); fclose( lib_module );
return 1; return true;
} }
} }
...@@ -565,20 +571,23 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, ...@@ -565,20 +571,23 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
LineNum = 0; LineNum = 0;
rewind( lib_module); rewind( lib_module);
GetLine( lib_module, Line, &LineNum ); // Copy footprints, until the old footprint to delete
while( GetLine( lib_module, Line, &LineNum ) ) bool skip_header = true;
{
StrPurge( Line );
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
break;
}
/* Copy footprints, until the old footprint to delete */
while( GetLine( lib_module, Line, &LineNum ) ) while( GetLine( lib_module, Line, &LineNum ) )
{ {
StrPurge( Line ); StrPurge( Line );
if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 ) if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 )
continue; continue;
// Search fo the beginning of module section:
if( skip_header )
{
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
skip_header = false;
else
continue;
}
if( strnicmp( Line, "$MODULE", 7 ) == 0 ) if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{ {
sscanf( Line + 7, " %s", Name ); sscanf( Line + 7, " %s", Name );
......
release version: release version:
2011 jul 07 2011 jul 08
files (.zip,.tgz): files (.zip,.tgz):
kicad-2011-07-07 kicad-2011-07-08
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment