Re: qt4: more cleanup

2006-05-07 Thread Andre Poenitz
On Sat, May 06, 2006 at 01:10:08PM +0300, Martin Vermeer wrote: > char const * using_this_returned_value_is_undefined_behaviour() > { > char const * cdata = std::string("data").c_str(); > return cdata; > } > > I think I understand this. The problem is that cdata is made to point to > the start

Re: qt4: more cleanup

2006-05-07 Thread Andre Poenitz
On Sat, May 06, 2006 at 12:07:54AM +0200, Edwin Leuven wrote: > Angus Leeming wrote: > >LOL! I think You are. You've confused this with "const &" > > and to add to the confusion (at least mine): > > why don't i see any invalid behavior or crashes with my original (wrong) > patch? Because 'undef

Re: qt4: more cleanup

2006-05-06 Thread Martin Vermeer
On Sat, May 06, 2006 at 12:07:54AM +0200, Edwin Leuven wrote: > Angus Leeming wrote: > >LOL! I think You are. You've confused this with "const &" > > and to add to the confusion (at least mine): > > why don't i see any invalid behavior or crashes with my original (wrong) > patch? char const * u

Re: qt4: more cleanup

2006-05-05 Thread Angus Leeming
Edwin Leuven <[EMAIL PROTECTED]> writes: Angus> LOL! I think You are. You've confused this with "const &" Edwin> and to add to the confusion (at least mine): Edwin> why don't i see any invalid behavior or crashes Edwin> with my original (wrong) patch? The term is "undefined behaviour". Sometimes

Re: qt4: more cleanup

2006-05-05 Thread Edwin Leuven
Angus Leeming wrote: LOL! I think You are. You've confused this with "const &" and to add to the confusion (at least mine): why don't i see any invalid behavior or crashes with my original (wrong) patch?

Re: qt4: more cleanup

2006-05-05 Thread Angus Leeming
Abdelrazak Younes <[EMAIL PROTECTED]> writes: Angus> Hmmm. How does your example differ from mine? Angus> char const * using_this_returned_value_is_undefined_behaviour() Angus> { Angus> char const * cdata = std::string("data").c_str(); Angus> return cdata; Angus> } Angus> The lifetime of std:

Re: qt4: more cleanup

2006-05-05 Thread Abdelrazak Younes
Angus Leeming a écrit : Abdelrazak Younes <[EMAIL PROTECTED]> writes: The temporary QCString object created as return value of 'fromUnicode' will be destroyed at the end of the full expression, i.e. basically at the semicolon in the first line. No, it is a QByteArray and QByteArray::data() retur

Re: qt4: more cleanup

2006-05-05 Thread Angus Leeming
Abdelrazak Younes <[EMAIL PROTECTED]> writes: > > The temporary QCString object created as return value of 'fromUnicode' > > will be destroyed at the end of the full expression, i.e. basically at > > the semicolon in the first line. > > No, it is a QByteArray and QByteArray::data() returns explici

Re: qt4: more cleanup

2006-05-05 Thread Abdelrazak Younes
Andre Poenitz a écrit : On Fri, May 05, 2006 at 09:31:14PM +0200, Abdelrazak Younes wrote: No it is char const * issue. I said remove the const and it will be all right: char * foo = codec->fromUnicode(str).data(); return foo[0]; This should work on VC++ and gcc. This is undefined behaviou

Re: qt4: more cleanup

2006-05-05 Thread Andre Poenitz
On Fri, May 05, 2006 at 09:31:14PM +0200, Abdelrazak Younes wrote: > No it is char const * issue. I said remove the const and it will be all > right: > > char * foo = codec->fromUnicode(str); > return foo[0]; > > This should work on VC++ and gcc. This is undefined behaviour. The temporary QCS

Re: qt4: more cleanup

2006-05-05 Thread Abdelrazak Younes
Abdelrazak Younes a écrit : char * foo = codec->fromUnicode(str); make it rather : char * foo = codec->fromUnicode(str).data(); This is a typo. return foo[0]; This should work on VC++ and gcc. _But_ note that I didn't recommend that, I recommended: return codec->fromUnicode(str)[0];

Re: qt4: more cleanup

2006-05-05 Thread Abdelrazak Younes
Andre Poenitz a écrit : On Thu, May 04, 2006 at 11:16:46PM +0200, Edwin Leuven wrote: Andre Poenitz wrote: On Thu, May 04, 2006 at 10:05:41AM +0200, Edwin Leuven wrote: - Q3CString tmpstr = codec->fromUnicode(str); - char const * tmpcstr = tmpstr; + char const * tmpcstr = cod

Re: qt4: more cleanup

2006-05-05 Thread Andre Poenitz
On Thu, May 04, 2006 at 11:16:46PM +0200, Edwin Leuven wrote: > Andre Poenitz wrote: > >On Thu, May 04, 2006 at 10:05:41AM +0200, Edwin Leuven wrote: > >>- Q3CString tmpstr = codec->fromUnicode(str); > >>- char const * tmpcstr = tmpstr; > >>+ char const * tmpcstr = codec->fromUnicode(str).dat

Re: qt4: more cleanup

2006-05-05 Thread Andre Poenitz
On Thu, May 04, 2006 at 11:46:09PM +0200, Abdelrazak Younes wrote: > 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++

Re: qt4: more cleanup

2006-05-04 Thread Abdelrazak Younes
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 cra

Re: qt4: more cleanup

2006-05-04 Thread Edwin Leuven
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 equival

Re: qt4: more cleanup

2006-05-04 Thread Abdelrazak Younes
Edwin Leuven wrote: Andre Poenitz wrote: On Thu, May 04, 2006 at 10:05:41AM +0200, Edwin Leuven wrote: -Q3CString tmpstr = codec->fromUnicode(str); -char const * tmpcstr = tmpstr; +char const * tmpcstr = codec->fromUnicode(str).data(); return tmpcstr[0]; } fromUnicode() retu

Re: qt4: more cleanup

2006-05-04 Thread Edwin Leuven
Andre Poenitz wrote: On Thu, May 04, 2006 at 10:05:41AM +0200, Edwin Leuven wrote: - Q3CString tmpstr = codec->fromUnicode(str); - char const * tmpcstr = tmpstr; + char const * tmpcstr = codec->fromUnicode(str).data(); return tmpcstr[0]; } fromUnicode() returns a tem

Re: qt4: more cleanup

2006-05-04 Thread Andre Poenitz
On Thu, May 04, 2006 at 10:05:41AM +0200, Edwin Leuven wrote: > - Q3CString tmpstr = codec->fromUnicode(str); > - char const * tmpcstr = tmpstr; > + char const * tmpcstr = codec->fromUnicode(str).data(); > return tmpcstr[0]; > } fromUnicode() returns a temporary object that will

Re: qt4: more cleanup

2006-05-04 Thread Abdelrazak Younes
Angus Leeming a écrit : Abdelrazak Younes <[EMAIL PROTECTED]> writes: Edwin> the attached works for me Edwin> - Q3CString tmpstr = codec->fromUnicode(str); Edwin> - char const * tmpcstr = tmpstr; Edwin> + char const * tmpcstr = codec->fromUnicode(str).data(); Abdel> Maybe: Abdel>

Re: qt4: more cleanup

2006-05-04 Thread Angus Leeming
Abdelrazak Younes <[EMAIL PROTECTED]> writes: Edwin> the attached works for me Edwin> -Q3CString tmpstr = codec->fromUnicode(str); Edwin> -char const * tmpcstr = tmpstr; Edwin> +char const * tmpcstr = codec->fromUnicode(str).data(); Abdel> Maybe: Abdel> return codec->fromU

Re: qt4: more cleanup

2006-05-04 Thread Abdelrazak Younes
Edwin Leuven a écrit : Abdelrazak Younes wrote: // more tricky? QLyXKeySym.C:#include Maybe not. the attached works for me [...] - Q3CString tmpstr = codec->fromUnicode(str); - char const * tmpcstr = tmpstr; + char const * tmpcstr = codec->fromUnicode(str).data(); May

Re: qt4: more cleanup

2006-05-04 Thread Edwin Leuven
Abdelrazak Younes wrote: // more tricky? QLyXKeySym.C:#include Maybe not. the attached works for me Index: src/frontends/qt4/QLyXKeySym.C === --- src/frontends/qt4/QLyXKeySym.C (revision 13796) +++ src/frontends/qt4/QLyXKe

Re: qt4: more cleanup

2006-05-04 Thread Edwin Leuven
Abdelrazak Younes wrote: Sorry, I don't have the time to review the patch but if you say you have tested it and it works I trust you :-) i of course tested it and found no issues (not that i am infallible though... ;-) it is in. thanks ed.

Re: qt4: more cleanup

2006-05-03 Thread Abdelrazak Younes
Edwin Leuven a écrit : patch attached this is what is left: // pref dialog QPrefColorsUi.ui: q3listbox.h qcoloritem.h:#include QPrefConvertersUi.ui: q3listbox.h QPrefCopiersUi.ui: q3listbox.h QPrefFileformatsUi.ui: q3listbox.h QPrefsDialog.C: Q3ListBoxItem * const item = // more t

qt4: more cleanup

2006-05-03 Thread Edwin Leuven
patch attached this is what is left: // pref dialog QPrefColorsUi.ui: q3listbox.h qcoloritem.h:#include QPrefConvertersUi.ui: q3listbox.h QPrefCopiersUi.ui: q3listbox.h QPrefFileformatsUi.ui: q3listbox.h QPrefsDialog.C: Q3ListBoxItem * const item = // more tricky? QLyXKeySym.C:#in