PDA

View Full Version : QString .toStdString heap bug



bpetty
3rd October 2006, 16:36
I don't know if it is just me... but I am using 4.1.4 and my program keeps crashing.

The problem is this. I call a function. In that function I have a text widget that I do a .toStdString() on like so:

string sTemp = ui.leServerDir->text().toStdString();

I am compiling this with VS2003 by the way. The problem is that when the function returns it crashes. It has a problem deallocating the heap for some reason. It does this if sTemp is over 16 characters minus the null term character (so 17). The program doesn't crash when you do this, however:

string sTemp = "00000000000000000000";

I also tried this... and it crashes:

QString sTemp = ui.leServerDir->text().toStdString().c_str();

For some reason QString wouldn't work with "std::string" so I had to convert it to a c string. Doesn't matter, it still crashes when the function cleans up.

An I doing something wrong? Hopefully this wont be an issue with the new version.

jacek
3rd October 2006, 17:10
Can you create a minimal, compilable example, so we can check if it crashes on our systems too?