kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #19800
Re: [PATCH] Fix 1485352: proejct_rescue invalid library file for projects with space in name
Crap. Been working on other projects lately. Here you go
On Mon, Aug 17, 2015 at 04:54:30PM -0400, Wayne Stambaugh wrote:
> Please check your curly bracket formatting.
>
>
> On 8/17/2015 4:52 PM, Chris Pavlina wrote:
> > Hi,
> >
> > project_rescue creates invalid library files for projects with
> > whitespace in the name (I mistakenly thought that these would be escaped
> > on export). Here's a patch to find and replace whitespace.
> >
> > --
> > Chris
> >
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help : https://help.launchpad.net/ListHelp
> >
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
commit b939bf78c6748587d21ec0144db6ef30fdd1f459
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date: Mon Aug 17 16:41:50 2015 -0400
Fix 1485352: rescue creates invalid file for project with spaces
diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp
index 6d3371d..098d3a3 100644
--- a/eeschema/project_rescue.cpp
+++ b/eeschema/project_rescue.cpp
@@ -33,6 +33,7 @@
#include <schframe.h>
#include <wildcards_and_files_ext.h>
+#include <cctype>
#include <boost/foreach.hpp>
#include <map>
@@ -331,7 +332,7 @@ public:
typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t;
candidate_map_t candidate_map;
- wxString part_name_suffix = wxT( "-RESCUE-" ) + aRescuer.GetPrj()->GetProjectName();
+ wxString part_name_suffix = aRescuer.GetPartNameSuffix();
BOOST_FOREACH( SCH_COMPONENT* each_component, *( aRescuer.GetComponents() ) )
{
@@ -497,6 +498,22 @@ void RESCUER::UndoRescues()
}
+wxString RESCUER::GetPartNameSuffix()
+{
+ wxString suffix = wxT( "-RESCUE-" );
+ wxString pname = GetPrj()->GetProjectName();
+ for( size_t i = 0; i < pname.Len(); ++i )
+ {
+ if( isspace( pname[i].GetValue() ) )
+ suffix.Append( '_' );
+ else
+ suffix.Append( pname[i] );
+ }
+
+ return suffix;
+}
+
+
bool SCH_EDIT_FRAME::RescueProject( bool aRunningOnDemand )
{
RESCUER rescuer( *this, Prj() );
diff --git a/eeschema/project_rescue.h b/eeschema/project_rescue.h
index a179914..4ba538f 100644
--- a/eeschema/project_rescue.h
+++ b/eeschema/project_rescue.h
@@ -162,6 +162,12 @@ public:
PROJECT* GetPrj() { return m_prj; }
/**
+ * Function GetPartNameSuffix
+ * Return the suffix to add to rescued parts.
+ */
+ wxString GetPartNameSuffix();
+
+ /**
* Function InvokeDialog
* Display a dialog to allow the user to select rescues.
* @param aAskShowAgain - whether the "Never Show Again" button should be visible
Follow ups
References