PDA

View Full Version : SOLVED: QVector<QWidget*> problem



vectori
7th July 2009, 12:19
Hi All!

This sounds pretty basic stuff but I'm having problem with QVector.

I'm using Qt 4.5.2
The code is below.

in header:

QVector<QWidget*> *m_activeWidgets;


in cpp:

QWidget* widget = new QWidget();
this->m_activeWidgets->append( widget );


result:
It crashes on append method.
in qvector.h

paste:

void QVector<T>::append(const T &t)
{
if (d->ref != 1 || d->size + 1 > d->alloc) { <--- at here *******************
const T copy(t);
realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + 1, sizeof(T),
QTypeInfo<T>::isStatic));
if (QTypeInfo<T>::isComplex)
new (d->array + d->size) T(copy);
else
d->array[d->size] = copy;
} else {
if (QTypeInfo<T>::isComplex)
new (d->array + d->size) T(t);
else
d->array[d->size] = t;
}
++d->size;
}

paste:qbasicatomic.h


inline bool operator!=(int value) const
{
return _q_value != value; <-- crash *******************
}

I don't know is it any help but it seems like _q_value doesn't have any value in debugger.
Any ideas?

- Vectori

AcerExtensa
7th July 2009, 12:52
have you forget to create your vector?


m_activeWidgets = new QVector<QWidget*>();

vectori
7th July 2009, 13:16
Hi,

Thanks for help!
You were absolutely right! I hadn't create that QVector at all..
Too much coding in busy gets thoughts messed up.

Amazingly I used few hours solving this problem :D
And I hadn't any clue at all.

- Vectori

AcerExtensa
7th July 2009, 13:20
Too much coding in busy gets thoughts messed up.
that's for sure.... :D