QVector::size() makes program crash
Solved
General and Desktop
-
Hi all.
I have a function that looks like this
void IconWidget::changePixmap(int newIndex) { if (newIndex < pixmaps.size()) index = newIndex; updatePixmap(); }
pixmaps is declared as
typedef struct { Pixmap::Index index; QPixmap lightNormal; QPixmap lightActive; QPixmap darkNormal; QPixmap darkActive; } PixmapItem; QVector<PixmapItem> pixmaps;
When I call. QVector::size(), then the program crashes with a segfault.
Any ideas? -
@Jakob-Clausen I would say, it's not breaking on the size call, but on the function entry point, on the very first thing it has to do with a member variable.
from top right I would say your IconWidget instance is invalid (null)
-
That is interesting.
If I replace the first line in the function with something likeqDebug() << "hello";
Then it also crashes. If you are right, is this what is to be expected?
-
@Jakob-Clausen jepp
-
Ok. Maybe not quite that.
But your input helped me track down what the problem really was.
Thank you very much for your help.