summaryrefslogtreecommitdiffstats
path: root/Tools/idle/EditorWindow.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-06-25 16:06:29 (GMT)
committerGuido van Rossum <guido@python.org>1999-06-25 16:06:29 (GMT)
commit205afb487a4ed9a70b0360da47402d2409aa9ed1 (patch)
tree162010ad9a447e02f82c1e89bf20f297bc7828ce /Tools/idle/EditorWindow.py
parentdd4dda87c1b80e709417664487dfa7ab5581f4e6 (diff)
downloadcpython-205afb487a4ed9a70b0360da47402d2409aa9ed1.zip
cpython-205afb487a4ed9a70b0360da47402d2409aa9ed1.tar.gz
cpython-205afb487a4ed9a70b0360da47402d2409aa9ed1.tar.bz2
Add _close() method that does the actual cleanup (close() asks the
user what they want first if there's unsaved stuff, and may cancel). It closes more than before. Add unload_extensions() method to unload all extensions; called from _close(). It calls an extension's close() method if it has one.
Diffstat (limited to 'Tools/idle/EditorWindow.py')
-rw-r--r--Tools/idle/EditorWindow.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/Tools/idle/EditorWindow.py b/Tools/idle/EditorWindow.py
index 0f23b15..007a99b 100644
--- a/Tools/idle/EditorWindow.py
+++ b/Tools/idle/EditorWindow.py
@@ -462,22 +462,38 @@ class EditorWindow:
self.top.tkraise()
reply = self.maybesave()
if reply != "cancel":
- WindowList.unregister_callback(self.postwindowsmenu)
- if self.close_hook:
- self.close_hook()
- colorizing = 0
- if self.color:
- colorizing = self.color.colorizing
- doh = colorizing and self.top
- self.color.close(doh) # Cancel colorization
- if not colorizing:
- self.top.destroy()
+ self._close()
return reply
+ def _close(self):
+ WindowList.unregister_callback(self.postwindowsmenu)
+ if self.close_hook:
+ self.close_hook()
+ self.flist = None
+ colorizing = 0
+ self.unload_extensions()
+ self.io.close(); self.io = None
+ self.undo = None # XXX
+ if self.color:
+ colorizing = self.color.colorizing
+ doh = colorizing and self.top
+ self.color.close(doh) # Cancel colorization
+ self.text = None
+ self.vars = None
+ self.per.close(); self.per = None
+ if not colorizing:
+ self.top.destroy()
+
def load_extensions(self):
self.extensions = {}
self.load_standard_extensions()
+ def unload_extensions(self):
+ for ins in self.extensions.values():
+ if hasattr(ins, "close"):
+ ins.close()
+ self.extensions = {}
+
def load_standard_extensions(self):
for name in self.get_standard_extension_names():
try: