← Back to team overview

kicad-developers team mailing list archive

Re: Bug in Libedit - Field edit dialog

 

--0016364c76a782afbf048033b19b Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello again,

After a bit of gdb debugging I found that there is a bug in the =3D
operator of LIB_FIELD. It was not copying m_Name. I've attached a
patch to fix this bug.

Best Regards,

Brian Sidebotham.

On 19 February 2010 19:17, Brian Sidebotham <brian.sidebotham@...> wr=
ote:
> 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:
>
> =A0 =A0// Sort files by field id, because they are not entered by id
> =A0 =A0sort(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:
>
> =A0 =A0wxString debugInfo;
>
> =A0 =A0debugInfo << wxT("The following fields are setup before sort():\n"=
);
> =A0 =A0for( size_t ii =3D 0; ii < m_FieldsBuf.size(); ii++ )
> =A0 =A0{
> =A0 =A0 =A0 =A0debugInfo << wxT("Field ID: ") << m_FieldsBuf[ii].m_FieldI=
d
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<< wxT("| FieldName: ") << m_FieldsBuf=
[ii].m_Name.c_str()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<< wxT("| FieldText: ") <<
> m_FieldsBuf[ii].m_Text.c_str() << wxT("\n");
> =A0 =A0}
>
> =A0 =A0// Sort files by field id, because they are not entered by id
> =A0 =A0sort(m_FieldsBuf.begin(), m_FieldsBuf.end(), SortFieldsById);
>
> =A0 =A0// Now, all fields exist and are sorted, init default names and se=
t row inf
> =A0 =A0debugInfo << wxT("The following fields are setup before setrowitem=
():\n");
> =A0 =A0for( size_t ii =3D 0; ii < m_FieldsBuf.size(); ii++ )
> =A0 =A0{
> =A0 =A0 =A0 =A0debugInfo << wxT("Field ID: ") << m_FieldsBuf[ii].m_FieldI=
d
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<< wxT("| FieldName: ") << m_FieldsBuf=
[ii].m_Name.c_str()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<< wxT("| FieldText: ") <<
> m_FieldsBuf[ii].m_Text.c_str() << wxT("\n");
> =A0 =A0}
>
> =A0wxMessageBox(debugInfo);
>
> ---------------------------------------------------------------
>
> The output of the message box is as follows:
>
> =A0The following fields are present before sort:
>
> =A0Field 0 | FieldName: | FieldText: SW
> =A0Field 1 | FieldName: /Chip Name| FieldText: NKK_SWITCH
> =A0Field 4 | FieldName: Manufacturer | FieldText: NKK
> =A0Field 2 | FieldName: | FieldText:
> =A0...
> =A0All the rest of the fields are the same as field 2
>
> The following fields are present before setrowitem():
>
> =A0Field 0 | FieldName: | FieldText: SW
> =A0Field 1 | FieldName: /Chip Name| FieldText: NKK_SWITCH
> =A0Field 2 | FieldName: Manufacturer | FieldText:
> =A0Field 3 | FieldName: | FieldText:
> =A0Field 4 | FieldName: | FieldText: NKK
> =A0...
> 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 =A0-50 0 =A0-25 0 N
> P 2 1 1 0 =A0-25 0 =A025 25 N
> P 2 1 1 0 =A050 0 =A025 0 N
> P 4 1 1 0 =A0-100 50 =A0-50 50 =A0-50 -50 =A0-100 -50 N
> P 4 1 1 0 =A0100 -50 =A050 -50 =A050 50 =A0100 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 =A0-25 0 =A0-50 0 N
> P 2 2 1 0 =A050 0 =A025 0 N
> P 5 2 1 0 =A020 50 =A040 70 =A040 60 =A030 70 =A040 70 N
> P 6 2 1 0 =A0-20 50 =A00 70 =A0-10 70 =A00 60 =A00 70 =A00 70 N
> P 7 2 1 0 =A0-25 25 =A0-25 -25 =A025 0 =A025 25 =A025 -25 =A025 0 =A0-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.
>
 --0016364c76a782afbf048033b19b Content-Type: application/octet-stream; name="fieldName.patch"
Content-Disposition: attachment; filename="fieldName.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_g5zjcoh10

[Attachment content not displayed.] --0016364c76a782afbf048033b19b-- 




References