Hi!
I would like to know why the following code shows me an error message when i run my program. I have no compile error message, just when i start the program. I commented some line to you understand better the code.
QList<QVector<Number> > Game::dozensSeqDrawn(int tm) {
int acum, ini, aux[size]; // size is 1786
ini = setStartRead( tm ); // sets a start point to read the matrix
QList<QVector<Number>> pl; //Number has (int val, int acum) as attributes
for(int dz = 0; dz < 6; dz++) {
arrayResetZero(aux, size); // sets to 0 each cell in the array
acum = 0;
for(int i = ini; i < size; i++) {
if( dozenInArray(historic[i], dz) ) {//historic[i] is a qvector
acum++;
}
else if(acum > 0) {
aux[(acum - 1)] += 1;
acum = 0;
}
}
pl.push_back( seqDrawnVector(aux, size) );
}
return pl;
}
QVector<Number> Game::seqDrawnVector(int array[], int length) {
QVector<Number> list;
for(int i = 0; i < length; i++)
if(array[i] != 0)
list.push_back( Number((i + 1), array[i]) );
return list;
}
QList<QVector<Number> > Game::dozensSeqDrawn(int tm) {
int acum, ini, aux[size]; // size is 1786
ini = setStartRead( tm ); // sets a start point to read the matrix
QList<QVector<Number>> pl; //Number has (int val, int acum) as attributes
for(int dz = 0; dz < 6; dz++) {
arrayResetZero(aux, size); // sets to 0 each cell in the array
acum = 0;
for(int i = ini; i < size; i++) {
if( dozenInArray(historic[i], dz) ) {//historic[i] is a qvector
acum++;
}
else if(acum > 0) {
aux[(acum - 1)] += 1;
acum = 0;
}
}
pl.push_back( seqDrawnVector(aux, size) );
}
return pl;
}
QVector<Number> Game::seqDrawnVector(int array[], int length) {
QVector<Number> list;
for(int i = 0; i < length; i++)
if(array[i] != 0)
list.push_back( Number((i + 1), array[i]) );
return list;
}
To copy to clipboard, switch view to plain text mode
ASSERT failure in QList<T>:: operator[]: "index out of range", file /usr/include/qt/QtCore/qlist.h, line 518
Aborted (core dumped)
I tried to change a little bit my code to this:
QList<QVector<Number> > Game::dozensSeqDrawn(int tm) {
QList<QVector<Number>> pl; //Number has (int val, int acum) as attributes
QVector<Number> line;
line.push_back(Number(-1, -1));
line.push_back(Number(-1, -1));
line.push_back(Number(-1, -1));
pl.push_back( line );
return pl;
}
QList<QVector<Number> > Game::dozensSeqDrawn(int tm) {
QList<QVector<Number>> pl; //Number has (int val, int acum) as attributes
QVector<Number> line;
line.push_back(Number(-1, -1));
line.push_back(Number(-1, -1));
line.push_back(Number(-1, -1));
pl.push_back( line );
return pl;
}
To copy to clipboard, switch view to plain text mode
Same error message.
Bookmarks