changeset: 77175:4334964993b9 branch: 2.7 parent: 77171:dc9ddad40bba user: Terry Jan Reedy date: Sat May 26 20:33:32 2012 -0400 files: Lib/idlelib/IOBinding.py Lib/idlelib/PyShell.py Misc/NEWS description: Issue #10365: File open dialog now works instead of crashing even when parent window is closed. Patch by Roger Serwy. diff -r dc9ddad40bba -r 4334964993b9 Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py Sat May 26 16:55:43 2012 -0400 +++ b/Lib/idlelib/IOBinding.py Sat May 26 20:33:32 2012 -0400 @@ -196,7 +196,8 @@ 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: @@ -207,16 +208,22 @@ # 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: diff -r dc9ddad40bba -r 4334964993b9 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sat May 26 16:55:43 2012 -0400 +++ b/Lib/idlelib/PyShell.py Sat May 26 20:33:32 2012 -0400 @@ -1458,7 +1458,8 @@ if tkversionwarning: shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) - root.mainloop() + while flist.inversedict: # keep IDLE running while files are open. + root.mainloop() root.destroy() if __name__ == "__main__": diff -r dc9ddad40bba -r 4334964993b9 Misc/NEWS --- a/Misc/NEWS Sat May 26 16:55:43 2012 -0400 +++ b/Misc/NEWS Sat May 26 20:33:32 2012 -0400 @@ -64,6 +64,9 @@ Library ------- +- Issue #10365: File open dialog now works instead of crashing + even when parent window is closed. Patch by Roger Serwy. + - Issue #14876: Use user-selected font for highlight configuration. Patch by Roger Serwy.

AltStyle によって変換されたページ (->オリジナル) /