Sunday, May 17, 2009

Eventually fixed!

Some bugs live with your application and sometimes are really hard to be noticed! The last one was in this category. All tests show that all components of the tested component work, but unfortunately, it did not from outside. What should it be?

If you take NaroCAD till this Sunday and you do this simple steps: make an extrude twice, do an undo, make the second extrude again and do twice undo, you should have no extrude. But you will see that one extrude is floating still. Eventually seems to me that was the second extrude (from the list of three created).

But why? Making first day of debugging session I eliminated the possibility of wrong computing diffs or not applying correctly the undo. After more research I removed the possibility of Extrude to do a wrong-doing in document live cycle. The single thing that remains in my mind was: it is a leak that is floating, and try to find it...

After a long research and trying to make small breaks, I remained out of ideas.

Eventually, I made assurances not by debugging but in code also that all parts are right, one by one. So I found that the diffs was computed wrong. Means that they were wrong from what was visual and what was computed. The diff in undo was computed right, but the trees eventually seemed wrong. The cause seems to be that after applying Undo, I did not make the compare point as previous.

So as a simple sketch: and you have 3 stages, A, B and C. And you will go from A to C like: A->B->C

When you do an Undo, you will go one step before C, so you will have A->B. The bad thing is that when you do: A->B->D, in old code, the diff was made between C and D, not B and D, and all went wrong.

That was really a well hidden bug, but the great thing is that at least undo/redo and at least all workflow of data between rectangle, reference subshape and extrude works flawlessly and is checked countless times, also in all relations between undo, redo and events like removal of them!

No comments: