Pcbnew: fix Bug #1395594 (pcbplotparams parser sensitive to formatting)
Looked like a minor issue, but was due to a more serious bug, when using 2 different DSN_LEXERS which were not synchronized. The fix is not perfect, but unfortunately, the parser used to read the PCB_PLOT_PARAMS in .kicad_pcb files is also used in legacy board file reader. Therefore it is better than write 2 parser functions, one for legacy files, the other for the .kicad_pcb files, which make the same thing.
This commit is contained in:
parent
0ac378fad7
commit
0e996cac9e
|
@ -148,6 +148,34 @@ void DSNLEXER::SetSpecctraMode( bool aMode )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DSNLEXER::SyncLineReaderWith( DSNLEXER& aLexer )
|
||||||
|
{
|
||||||
|
// Synchronize the pointers handling the data read by the LINE_READER
|
||||||
|
// only if aLexer shares the same LINE_READER, because only in this case
|
||||||
|
// the char buffer can be common
|
||||||
|
|
||||||
|
if( reader != aLexer.reader )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Be sure the char buffer is common
|
||||||
|
if( reader->Line() != aLexer.reader->Line() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// We can synchronize the pointers which handle the data currently read
|
||||||
|
start = aLexer.start;
|
||||||
|
next = aLexer.next;
|
||||||
|
limit = aLexer.limit;
|
||||||
|
|
||||||
|
// Sync these parameters is not mandatory, but could help
|
||||||
|
// for instance in debug
|
||||||
|
curText = aLexer.curText;
|
||||||
|
curOffset = aLexer.curOffset;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DSNLEXER::PushReader( LINE_READER* aLineReader )
|
void DSNLEXER::PushReader( LINE_READER* aLineReader )
|
||||||
{
|
{
|
||||||
readerStack.push_back( aLineReader );
|
readerStack.push_back( aLineReader );
|
||||||
|
|
|
@ -71,7 +71,7 @@ enum DSN_SYNTAX_T {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DLEXER
|
* Class DSNLEXER
|
||||||
* implements a lexical analyzer for the SPECCTRA DSN file format. It
|
* implements a lexical analyzer for the SPECCTRA DSN file format. It
|
||||||
* reads lexical tokens from the current LINE_READER through the NextTok()
|
* reads lexical tokens from the current LINE_READER through the NextTok()
|
||||||
* function.
|
* function.
|
||||||
|
@ -215,6 +215,16 @@ public:
|
||||||
|
|
||||||
virtual ~DSNLEXER();
|
virtual ~DSNLEXER();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Useable only for DSN lexers which share the same LINE_READER
|
||||||
|
* Synchronizes the pointers handling the data read by the LINE_READER
|
||||||
|
* Allows 2 DNSLEXER to share the same current line, when switching from a
|
||||||
|
* DNSLEXER to an other DNSLEXER
|
||||||
|
* @param aLexer = the model
|
||||||
|
* @return true if the sync can be made ( at least the same line reader )
|
||||||
|
*/
|
||||||
|
bool SyncLineReaderWith( DSNLEXER& aLexer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetSpecctraMode
|
* Function SetSpecctraMode
|
||||||
* changes the behavior of this lexer into or out of "specctra mode". If
|
* changes the behavior of this lexer into or out of "specctra mode". If
|
||||||
|
|
|
@ -1135,12 +1135,14 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
|
||||||
{
|
{
|
||||||
PCB_PLOT_PARAMS plotParams;
|
PCB_PLOT_PARAMS plotParams;
|
||||||
PCB_PLOT_PARAMS_PARSER parser( reader );
|
PCB_PLOT_PARAMS_PARSER parser( reader );
|
||||||
|
// parser must share the same current line as our current PCB parser
|
||||||
|
// synchronize it.
|
||||||
|
parser.SyncLineReaderWith( *this );
|
||||||
|
|
||||||
plotParams.Parse( &parser );
|
plotParams.Parse( &parser );
|
||||||
m_board->SetPlotOptions( plotParams );
|
SyncLineReaderWith( parser );
|
||||||
|
|
||||||
// I don't know why but this seems to fix a problem in PCB_PLOT_PARAMS::Parse().
|
m_board->SetPlotOptions( plotParams );
|
||||||
NextTok();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <wx/wx.h>
|
//#include <wx/wx.h>
|
||||||
#include <pcb_plot_params_parser.h>
|
#include <pcb_plot_params_parser.h>
|
||||||
#include <pcb_plot_params.h>
|
#include <pcb_plot_params.h>
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
Loading…
Reference in New Issue