← Back to team overview

kicad-developers team mailing list archive

Bug in Libedit - Field edit dialog

 

Hi Guys,

First off, I'm compiling using MinGW 3.4.5, and testing under Windows XP.

I am looking at a bug, which appears to boil down to the following
line, which is in the InitBuffers() function:

// Sort files by field id, because they are not entered by id
sort(m_FieldsBuf.begin(), m_FieldsBuf.end(), SortFieldsById);

Here is some sanity checking code I included as I am not setup here to
run with gdb or any other debugger right now:

wxString debugInfo;

debugInfo << wxT("The following fields are setup before sort():\n");
for( size_t ii = 0; ii < m_FieldsBuf.size(); ii++ )
{
debugInfo << wxT("Field ID: ") << m_FieldsBuf[ii].m_FieldId
<< wxT("| FieldName: ") << m_FieldsBuf[ii].m_Name.c_str()
<< wxT("| FieldText: ") <<
m_FieldsBuf[ii].m_Text.c_str() << wxT("\n");
}

// Sort files by field id, because they are not entered by id
sort(m_FieldsBuf.begin(), m_FieldsBuf.end(), SortFieldsById);

// Now, all fields exist and are sorted, init default names and set row inf
debugInfo << wxT("The following fields are setup before setrowitem():\n");
for( size_t ii = 0; ii < m_FieldsBuf.size(); ii++ )
{
debugInfo << wxT("Field ID: ") << m_FieldsBuf[ii].m_FieldId
<< wxT("| FieldName: ") << m_FieldsBuf[ii].m_Name.c_str()
<< wxT("| FieldText: ") <<
m_FieldsBuf[ii].m_Text.c_str() << wxT("\n");
}

wxMessageBox(debugInfo);

---------------------------------------------------------------

The output of the message box is as follows:

The following fields are present before sort:

Field 0 | FieldName: | FieldText: SW
Field 1 | FieldName: /Chip Name| FieldText: NKK_SWITCH
Field 4 | FieldName: Manufacturer | FieldText: NKK
Field 2 | FieldName: | FieldText:
...
All the rest of the fields are the same as field 2

The following fields are present before setrowitem():

Field 0 | FieldName: | FieldText: SW
Field 1 | FieldName: /Chip Name| FieldText: NKK_SWITCH
Field 2 | FieldName: Manufacturer | FieldText:
Field 3 | FieldName: | FieldText:
Field 4 | FieldName: | FieldText: NKK
...
All the rest of the fields are empty

------------------------------------------------------------------
This is the component:

#
# NKK_SWITCH
#
DEF ~NKK_SWITCH SW 0 40 Y Y 2 F N
F0 "SW" 0 100 40 H V C CNN
F1 "NKK_SWITCH" 0 150 40 H I C CNN
F4 "NKK" 100 200 60 H V C CNN "Manufacturer"
DRAW
P 2 1 1 0 -50 0 -25 0 N
P 2 1 1 0 -25 0 25 25 N
P 2 1 1 0 50 0 25 0 N
P 4 1 1 0 -100 50 -50 50 -50 -50 -100 -50 N
P 4 1 1 0 100 -50 50 -50 50 50 100 50 N
X ~ 1 -150 50 50 R 40 40 1 1 I
X ~ 2 -150 -50 50 R 40 40 1 1 I
X ~ 3 150 50 50 L 40 40 1 1 I
X ~ 4 150 -50 50 L 40 40 1 1 I
P 2 2 1 0 -25 0 -50 0 N
P 2 2 1 0 50 0 25 0 N
P 5 2 1 0 20 50 40 70 40 60 30 70 40 70 N
P 6 2 1 0 -20 50 0 70 -10 70 0 60 0 70 0 70 N
P 7 2 1 0 -25 25 -25 -25 25 0 25 25 25 -25 25 0 -25 25 N
X ~ 5 -100 0 50 R 40 40 2 1 I
X ~ 6 100 0 50 L 40 40 2 1 I
ENDDRAW
ENDDEF

Sort is corrupting the buffer, but it looks like a sane call to
sort(). I have just downloaded the RC3a build, and this also exhibits
the same problem, so I don't think it's my build environment that is
bugged. I can't work out what is going on so I wondered if anyone
could point me in the right direction or see what is wrong themselves?

Best Regards,

Brian.






Follow ups