PDA

View Full Version : [ItemView] Bug in headerview



lauranger
11th August 2006, 17:44
Hi
I found a bug in the handling of column removal by headerview.
I found also the code error that give that mishandling.
The case :
3 columns, say A, B, C.
Move column C to first place. -> C,A,B.
Then remove column A -> Boom. Normally should get C,B

the current code :

for (int l = logicalLast; l >= logicalFirst; --l) {
int visual = visualIndices.at(l);
int size = sections.at(visual + 1).position - sections.at(visual).position;
for (int v = 0; v < sections.count(); ++v) {
if (logicalIndex(v) > l)
--(logicalIndices[v]);
if (v > visual) {
sections[v].position -= size;
int logical = logicalIndex(v);
--(visualIndices[logical]);
}
}
sections.remove(visual);
hiddenSectionSize.remove(l);

logicalIndices.remove(visual);
visualIndices.remove(l);

line 9/10 use value that line 7 may have changed.
it should be (80% sure ;) ) :


for (int l = logicalLast; l >= logicalFirst; --l) {
int visual = visualIndices.at(l);
int size = sections.at(visual + 1).position - sections.at(visual).position;
for (int v = 0; v < sections.count(); ++v) {
int logical = logicalIndex(v);
if (logicalIndex(v) > l)
--(logicalIndices[v]);
if (v > visual) {
sections[v].position -= size;
--(visualIndices[logical]);
}
}
sections.remove(visual);
hiddenSectionSize.remove(l);

logicalIndices.remove(visual);
visualIndices.remove(l);


What is the quickest way to get an official fix for that ?

I'm trying to recollect how to recompile Qt here :(
(I have already done it for 4.1.2)

Thanks.

jpn
11th August 2006, 17:51
What is the quickest way to get an official fix for that ?
"Open a new Task" at Task Tracker (http://www.trolltech.com/developer/task-tracker/).

gfunk
12th August 2006, 00:00
Ick... this code is so hard to read, I'm not surprised it has a bug. Nested loops using vectors like fixed-size arrays... ugh. Granted, organizing the header section probably isn't a UI operation that needs to be done too often, probably just on init, I imagine they did it for performance reasons for other view operations.

lauranger
14th August 2006, 12:55
I agree with you. We can consider it too "clever" for the frequency it is to be called.
I guess calculating just the visual indexes and then mapping back the logical indexes
would have suffice.