Edwin Leuven wrote:
Abdelrazak Younes wrote:
Andre Poenitz wrote:
fromUnicode() returns a temporary object that will be destoyed at the
end of the full expression. So tmpcstr will be invalid after that.

Accessing tmpcstr[0] after that will cause invalid behaviour (and almost
guaranteed a crash with the Qt4 equivalent on a VS 2005 release build).

und jetzt?

Which means "Et maintenant?" (so google say).

tout a fait

An now, take my solution or remove the const.

will take your solution then

could someone explain it to me?

fromUnicode return a temporary QByteArray; so is the internal char* that is returned by data(). So a const pointer will stay valid only during the current context (remember that char * is not a simple pointer in C and C++). A copy instead of a reference solve the problem.

Am I clear?

Abdel.


the qt docs say:

const char * data () const


thanks, ed.


Reply via email to