std::string destructor crashing in Release when using ::toStdString methods
-
I was recently working with Qt, overridden new/delete operator, and got the similar issue.
It caused a problem that QByteArray::toStdString() made a std::string which avoided calling the overridden version of new.
However, when the std::string was destructed in my program, it called the overridden version of delete. Bomb!
Maybe it is a reasonable practice to avoid using std::string returned by Qt or other 3rd party library. Or you should rebuild all of them with the exactly same environment.
-
@Hudson said:
Maybe it is a reasonable practice to avoid using std::string returned by Qt or other 3rd party library.
Actually in your case, forgive me for being so blunt, I'd say it would be a reasonable practice to avoid writing new/delete operators for classes you don't own (i.e. such that are not written by you). And as a side note creating
std::string
s in the heap is a bit questionable.Also I don't see how Qt could have called an overloaded
new
so you can calldelete
on it. There's nonew
inQByteArray::toStdString
,