[Qt-interest] QByteArray bug?
Frank Hemer
frank at hemer.org
Fri Jul 10 21:25:31 CEST 2009
On Friday 10 July 2009 21:02:27 Pascal Patry wrote:
> On Friday 10 July 2009 14:51:16 Frank Hemer wrote:
> > I have a Method:
> >
> > MyArray::getData (int len) {
> > QByteArray arr;
> > arr.resize (len);
> > arr.data ();
>
> Why are you calling 'arr.data()' if it's to do nothing with the returned
> ptr?
The code is just an excerpt.
Without that call it works fine:-(
> > return arr;
> > }
> >
> > >From another place, this is called:
> >
> > MyArray myArray;
> > QByteArray arr = myArray.getData (x);
> > qDebug ("arr size: %i", arr.size ());
> >
> > This works for all values of x
> > BUT NOT FOR 0??
> >
> > if x is zero, the array size printed seems to be unpredictable.
> >
> > Seems like a bug to me?!
> >
> > Found in qt4.4.2
> >
> > Frank
>
> I've tried this in Qt 4.5.1:
> ====
> int main(int /*argc*/, char ** /*argv*/)
> {
> QByteArray a;
> a.resize(0);
> a.data();
> qDebug("size of a: %d", a.size());
> return 0;
> }
>
> and the result is:
> => size of a: 0
It only fails if its in a method - the way you tried it works fine.
I'll see if I can post sample code ...
Frank
More information about the Qt-interest-old
mailing list