kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24049
Re: New pcbnew features and versioning
Here's a patch that checks the PCB file format version against the currently
supported one, and displays a message explaining the situation if the PCB file
is too recent. I assumed YYYYMMDD format for the version. Message looks like
this:
KiCad was unable to open this file, as it was created with a more recent
version than the one you are running. To open it, you'll need to upgrade
KiCad to a more recent version.
File: <filename>
Date of KiCad version required (or newer): <format version, reformatted as date in locale>
A couple changes still have to be made - this is only for comment, not to
commit.
1. Also check footprints - we'll have to add versioning to those, as it's not
there at all right now as JP said.
2. Use a more friendly error dialog without the "IO_ERROR" and source code
location, at least in non-debug builds. That will frighten people. :)
On Thu, Apr 07, 2016 at 09:47:41AM -0400, Chris Pavlina wrote:
> Hi all,
>
> I'm targeting this email primarily at Wayne as versioning and release policy is
> involved.
>
> We've got a bit of a problem right now. We're currently adding features to the
> pcbnew format - JP just merged rounded-rect pads and has a patch in development
> for custom pads, and I'm looking at a patch to add angled fields. Problem is:
>
> 1. We're not bumping the file format version, so even though we're writing
> files that contain features (actual COPPER features!) that old versions won't
> understand, we're not marking them as such, so they'll either give nasty
> file-corrupted errors, or fail to load silently.
>
> 2. Even if we did, pcbnew currently ignores the format version.
>
>
> I propose the following:
>
> 1. Patch pcbnew to check the format version and give a friendly "your KiCad may
> be out of date"-style warning if it's too high a number.
>
> 2. Accelerate this patch to a minor stable release to get it out there before
> these new features make it into the next major release.
>
> 3. Adopt a policy of properly bumping the version number any time a feature is
> added.
>
> Thoughts?
>
> -- Chris
>From ba8c7ec674811576639d760f3107e8f6ff6f8075 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.chris@xxxxxxxxx>
Date: Sat, 9 Apr 2016 11:37:21 -0400
Subject: [PATCH] Check the PCB file format version
---
pcbnew/pcb_parser.cpp | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp
index a6a373f..e4582c5 100644
--- a/pcbnew/pcb_parser.cpp
+++ b/pcbnew/pcb_parser.cpp
@@ -515,7 +515,28 @@ void PCB_PARSER::parseHeader() throw( IO_ERROR, PARSE_ERROR )
Expecting( GetTokenText( T_version ) );
// Get the file version.
- m_board->SetFileFormatVersionAtLoad( parseInt( GetTokenText( T_version ) ) );
+ int pcb_version = parseInt( GetTokenText( T_version ) );
+ m_board->SetFileFormatVersionAtLoad( pcb_version );
+
+ if( pcb_version > SEXPR_BOARD_FILE_VERSION )
+ {
+ wxASSERT( pcb_version > 4 ); // After version 4 we're switching to YYYYMMDD
+ int year, month, day;
+
+ year = pcb_version / 10000;
+ month = ( pcb_version / 100 ) - ( year * 100 );
+ day = pcb_version - ( year * 10000 ) - ( month * 100 );
+
+ wxDateTime date( day, (wxDateTime::Month)( month - 1 ), year, 0, 0, 0, 0 );
+ wxString error;
+ error.Printf( _( "KiCad was unable to open this file, as it was created with a more "
+ "recent version than the one you are running. To open it, you'll need "
+ "to upgrade KiCad to a more recent version.\n\n"
+ "File: %s\n"
+ "Date of KiCad version required (or newer): %s" ),
+ GetChars( CurSource() ), date.FormatDate() );
+ THROW_IO_ERROR( error );
+ }
// Skip the host name and host build version information.
NeedRIGHT();
--
2.8.0
Follow ups
References