Am Samstag, den 11.09.2010, 00:14 +0200 schrieb Pavel Sanda: > Uwe Stöhr wrote: > > Am 10.09.2010 20:49, schrieb Pavel Sanda: > > > >> do you understand why the code in r35299 > >> > >> string width_str = fromqstr(WidthLE->text()); > >> if (width_str[0] == '-') > >> width_str.erase(0,1); > >> > >> must crash sooner or later? > > > > No. I check if the string begins with a '-' sign and if so, I remove this > > character from the string because I want to turn it into a positive one > > without casting the string to a float and then back to a string. This works > > well here and doesn't crash. > > But as you know I'm a miserable programmer and it seems I have overseen > > something. > > the problem is what happens when width_str is empty. then no width_str[0] > exists and accessing it is asking for crash. > > pavel
if (WidthLE->text().startsWith('-')) { Peter