An error in QwtScaleDiv::invert
Hello,
I noticed an error in QwtScaleDiv::invert() (VS /analyze caught it) :
Code:
for ( int i = 0; i < NTickTypes; i++ )
{
QList<double>& ticks = d_ticks[i];
const int size = ticks.count();
const int size2 = size / 2;
for ( int i = 0; i < size2; i++ )
qSwap( ticks[i], ticks[size - 1 - i] );
}
I believe the second for() should use j or something instead of i.
Thanks!
Re: An error in QwtScaleDiv::invert
It's not a bug (assuming that the inner loop really should use a new loop variable). The inner for loop uses a new instance of variable i. Check the output of the following small program:
Code:
#include <iostream>
using namespace std;
int main(int , char**)
{
for (int i=0; i < 5; i++)
{
cout << i << " ";
for(int i=0; i < 3; i++)
if(i == 0)
cout << i << endl;
else
cout << " " << i << endl;
}
}
But I would also prefer a new name for the inner for loop variable just for code readability.
Re: An error in QwtScaleDiv::invert
Yes, you're right, I missed that.
Too much late-night debugging with suspicious tools, I guess... :)
Re: An error in QwtScaleDiv::invert
Uwe,
Regarding your commit; just pointing out that you don't increment the j variable in the inner loop:
Quote:
for ( int j = 0; j < size2; i++ )
qSwap( ticks[j], ticks[size - 1 - j] );