Plugins which bind instances of their implementing class to commanders need to 
know when the commander is being destroyed so they can unregister their 
handlers, otherwise they're called to do stuff on commanders which no longer 
exist.

A long standing irritation of mine, which I finally debugged, is that after I 
use 'Revert To Saved' I start getting lots of console messages like:

  skipping tag select3: c does not exists or does not have a frame.

This is because 'Revert To Saved' doesn't call g.doHook("close-frame",c=c), so 
plugins don't get a chance to unregister their hooks.  The trivial patch below 
fixes the problem.

BUT - does the plugin need to understand the difference between a frame being 
closed with the intent to discard changes (i.e. the 'Revert To Saved' case, and 
a frame being closed in a context where the plugin should save anything it's 
responsible for saving?

Should plugins only save things on save1 / save2 hooks?  Perhaps that's the 
best solution, adjust the docs so it's clear you shouldn't save things on a 
"close-frame" hook?

Certainly easier than introducing commander specific hooks, anyway :-)

So, I should push the change below?

Cheer -Terry

=== modified file 'leo/core/leoCommands.py'
--- leo/core/leoCommands.py     2010-03-08 06:58:41 +0000
+++ leo/core/leoCommands.py     2010-03-12 17:09:11 +0000
@@ -1418,6 +1418,7 @@
         ok, frame = g.openWithFileName(fileName,c)
         if ok:
             frame.deiconify()
+            g.doHook("close-frame",c=c)
             g.app.destroyWindow(c.frame)
         else:
             c.mFileName = fileName

-- 
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.

Reply via email to