]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #10365: File open dialog now works instead of crashing
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 27 May 2012 00:33:32 +0000 (20:33 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Sun, 27 May 2012 00:33:32 +0000 (20:33 -0400)
even when parent window is closed. Patch by Roger Serwy.

Lib/idlelib/IOBinding.py
Lib/idlelib/PyShell.py
Misc/NEWS

index c515432ddc613f857904e05c89ad76dbd3600037..e11253ef96b124a4191b2680681199fb22d3ef98 100644 (file)
@@ -196,7 +196,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:
@@ -207,16 +208,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:
index eeb33e1c75088fae6cec3cc577f46a901fafc4bf..eec0b70b4475eb1544c86f8295690f720dd2bf82 100644 (file)
@@ -1458,7 +1458,8 @@ def main():
     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__":
index 26ac7173009d461a133494aeef5f81d2c1490dcd..6a0ce9e13b2848e7d79fba7bd92f6b4d039f428b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -64,6 +64,9 @@ Core and Builtins
 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.