From 84572d371da02fb21760b4105f04cd0d88b0fbf8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 8 Jul 2011 09:12:28 +0200 Subject: [PATCH] Pcbnew: fix bug I recently created: footprint lib incorrectly saved (first module can be lost) --- bitmap2component/bitmap2component.cpp | 1 + common/build_version.cpp | 2 +- packaging/windows/nsis/install.nsi | 2 +- pcbnew/librairi.cpp | 39 ++++++++++++++++----------- version.txt | 4 +-- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index 89b32ffbc8..a47b98cf99 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -283,6 +283,7 @@ static void OuputHeader( BITMAPCONV_INFO& aInfo ) aInfo.m_PixmapWidth, aInfo.m_PixmapHeight ); fprintf( aInfo.m_Outfile, "$MODULE %s\n", CmpName ); 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", Ypos, fieldSize, fieldSize, fieldSize/5, FIELD_LAYER ); fprintf( aInfo.m_Outfile, "T1 0 %d %d %d 0 %d N I %d \"%s\"\n", diff --git a/common/build_version.cpp b/common/build_version.cpp index 9f86fc7363..43072e85a2 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -6,7 +6,7 @@ #endif #ifndef KICAD_BUILD_VERSION -#define KICAD_BUILD_VERSION "(2011-07-07)" +#define KICAD_BUILD_VERSION "(2011-07-08)" #endif diff --git a/packaging/windows/nsis/install.nsi b/packaging/windows/nsis/install.nsi index 3665fccc70..225dffcaf8 100644 --- a/packaging/windows/nsis/install.nsi +++ b/packaging/windows/nsis/install.nsi @@ -17,7 +17,7 @@ ; General Product Description Definitions !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 SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define COMPANY_NAME "" diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 9808c5a1fe..f85c34a31e 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -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 ) { int ii, NbModules = 0; - float Pas; MODULE* Module; wxString fileName = LibName, path; @@ -424,7 +423,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn for( ; Module != NULL; Module = (MODULE*) Module->Next() ) NbModules++; - Pas = (float) 100 / NbModules; + double step = 100.0 / NbModules; DisplayActivity( 0, wxEmptyString ); Module = (MODULE*) GetBoard()->m_Modules; @@ -434,7 +433,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn NewModulesOnly ? false : true, false ) == 0 ) break; - DisplayActivity( (int) ( ii * Pas ), wxEmptyString ); + DisplayActivity( (int) ( ii * step ), wxEmptyString ); /* Check for request to stop backup (ESCAPE key actuated) */ if( DrawPanel->m_AbortRequest ) break; @@ -485,12 +484,19 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, { wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp ); if( dlg.ShowModal() != wxID_OK ) - return 0; // cancelled by user + return false; // cancelled by user Name_Cmp = dlg.GetValue(); Name_Cmp.Trim( true ); Name_Cmp.Trim( false ); 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; } @@ -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 { fclose( lib_module ); - return 1; + return true; } } @@ -565,20 +571,23 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, LineNum = 0; rewind( lib_module); - GetLine( lib_module, Line, &LineNum ); - while( GetLine( lib_module, Line, &LineNum ) ) - { - StrPurge( Line ); - if( strnicmp( Line, "$MODULE", 7 ) == 0 ) - break; - } - - /* Copy footprints, until the old footprint to delete */ + // Copy footprints, until the old footprint to delete + bool skip_header = true; while( GetLine( lib_module, Line, &LineNum ) ) { StrPurge( Line ); if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 ) 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 ) { sscanf( Line + 7, " %s", Name ); diff --git a/version.txt b/version.txt index ce9efa3d82..7de67b9e61 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ release version: -2011 jul 07 +2011 jul 08 files (.zip,.tgz): -kicad-2011-07-07 +kicad-2011-07-08