summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/IOBinding.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2012-05-27 00:23:45 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2012-05-27 00:23:45 (GMT)
commitcd6b8c67ceb4230198de9cdc971b27848c5391f0 (patch)
tree5b351486ca2641e5cf46f59eff73a6b8707a0374 /Lib/idlelib/IOBinding.py
parent809309a4822124f46dc98514ccdf818564215f30 (diff)
downloadcpython-cd6b8c67ceb4230198de9cdc971b27848c5391f0.zip
cpython-cd6b8c67ceb4230198de9cdc971b27848c5391f0.tar.gz
cpython-cd6b8c67ceb4230198de9cdc971b27848c5391f0.tar.bz2
Issue #10365: File open dialog now works instead of crashing
even when parent window is closed. Patch by Roger Serwy.
Diffstat (limited to 'Lib/idlelib/IOBinding.py')
-rw-r--r--Lib/idlelib/IOBinding.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index d20c708..eb7f97b 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -156,7 +156,8 @@ class IOBinding:
self.filename_change_hook()
def open(self, event=None, editFile=None):
- if self.editwin.flist:
+ flist = self.editwin.flist
+ if flist:
if not editFile:
filename = self.askopenfile()
else:
@@ -167,16 +168,22 @@ class IOBinding:
# we open a new window. But we won't replace the
# shell window (which has an interp(reter) attribute), which
# gets set to "not modified" at every new prompt.
+ # Also, make sure the current window has not been closed,
+ # since it can be closed during the Open File dialog.
try:
interp = self.editwin.interp
except AttributeError:
interp = None
- if not self.filename and self.get_saved() and not interp:
- self.editwin.flist.open(filename, self.loadfile)
+
+ if self.editwin and not self.filename and \
+ self.get_saved() and not interp:
+ flist.open(filename, self.loadfile)
else:
- self.editwin.flist.open(filename)
+ flist.open(filename)
else:
- self.text.focus_set()
+ if self.text:
+ self.text.focus_set()
+
return "break"
#
# Code for use outside IDLE: