It looks like I shall have to abandon the 'redraw' branch and try
again with a 'redraw2' branch. This kind of failure is rare, but it
does sometimes happen.
The symptom of the failure are two failed unit tests:
1. @test paste at end of headline
I spent several hours yesterday tracking down why this works in the
trunk but not in the redraw branch. It turns out that
c.frame.tree.editLabel(p) sets the focus to the tree widget in the
trunk but not in the redraw branch. This is perplexing and impossible
to follow with pdb because pdb alters focus. What I do know is that:
a) g.app.gui.set_focus does not *immediately* set focus in either the
trunk or the redraw branch.
b) g.app.gui.set_focus does not *ever* set focus in the redraw branch
unless the call to w.focus_set is followed by a call to w.update.
This I absolutely refuse to do. It would be much preferable to
abandon the redraw branch than to insert this odious call: it's a huge
performance hit, and it's dangerous. You don't understand Tk if you
don't understand why w.update is to be avoided.
2. @test inserting a new node draws the screen exactly once
The whole point of the redraw branch is that eliminating c.begin/
endUpdate must work exactly like the old code. The failure of this
test indicates that the whole project has failed.
So I screwed up :-) In this kind of situation it is essential to
admit the mistake and move on. Unless I can find a *simple*
explanation for the failed unit tests (highly unlikely), I shall have
to start again with a new 'redraw2' branch.
So it's time for a postmortem.
Looking back, I was lulled into a false sense of security by the
apparent simplicity of c.begin/endUpdate and c.redraw/Now in the
*trunk*. Here is the present code (in the trunk):
def beginUpdate(self):
pass
def endUpdate(self,flag=True,scroll=True):
c = self
if flag:
c.requestRedrawFlag = True
c.requestRedrawScrollFlag = scroll
# g.trace('flag is True',c.shortFileName(),g.callers())
def redraw (self):
c = self
c.requestRedrawFlag = True
def redraw_now (self):
c = self
c.requestRedrawFlag = True
c.outerUpdate()
assert not c.requestRedrawFlag
Clearly, it should be possible to convert:
c.beginUpdate()
try:
<<whatever>>
finally:
c.endUpdate()
to:
<<whatever>>
c.endUpdate()
But that's not what I did. I converted the code to:
<<whatever>>
<<something else>>
where <<something else>> was usually c.redraw() and sometimes
c.redraw_now() and possibly even something else entirely. Big
mistake.
Furthermore, I tried to eliminate the callbacks created by c.bind,
c.bind2 and c.tag_bind. I hoped to be able to call c.outerUpdate
*explicitly* at the end of each command and event handler. Another
big mistake. Trying to "mark" all commands and event handlers adds
more complexity than c.begin/endUpdate does.
It appears the *combination* of these two mass changes created the bug
that can't be found or fix. I tried to restore the callbacks created
by c.bind, c.bind2 and c.tag_bind, but I probably didn't.
So the strategy for the redraw2 branch will be to be more careful :-)
I'll leave the callbacks strictly alone, and alter the code more
methodically, running unit tests as I go.
Before I do that, I must fix an important bug in the trunk. At
present, the screen doesn't scroll properly on startup when the
selected node is deep in the tree. This may be related to a recent
attempt at fixing another scrolling bug. In any event, it's got to be
fixed asap before b2 can be said to be ready.
Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---