Whenever I run my code I get an error stating the vector went out of bounds. The vector is declared as
QVector <CCell> grid;
To copy to clipboard, switch view to plain text mode
in a class, where CCell is just a class which contains a couple functions for setting its values.
So in this class that the vector is declared, I initialize it with
resize(width * height);
resize(width * height);
To copy to clipboard, switch view to plain text mode
So after breaking pointing the vector gets sized correctly to the value 600 (30 * 20).
So after investigating where this would error out it is this code here immediately from the constructor:
void CGrid::clearMap()
{
int i = 0;
int j = 0;
for(i = 0; i < width; i++)
{
for(j = 0; j < height; j++)
{
grid[i * width + j].setCellVal(0);
}
}
}
void CGrid::clearMap()
{
int i = 0;
int j = 0;
for(i = 0; i < width; i++)
{
for(j = 0; j < height; j++)
{
grid[i * width + j].setCellVal(0);
}
}
}
To copy to clipboard, switch view to plain text mode
for whatever reason when following this in breakpoints, j immediately is initialized to 0, then after going through the first for loop, it jumps immediately to 20 (or whatever the height value is), immediately throwing it out of bounds for the vector.
I have no code that changes this value to 20 or interacts with it, so there is no way that I can think of for it to do this.
Any ideas? I'm using the QtCreator 3 IDE with MSVC2010 compiler.
Bookmarks