mirror of
				https://github.com/python/cpython.git
				synced 2025-10-26 03:04:41 +00:00 
			
		
		
		
	Issue #10365: File open dialog now works instead of crashing
even when parent window is closed. Patch by Roger Serwy.
This commit is contained in:
		
							parent
							
								
									42f7b7ecb2
								
							
						
					
					
						commit
						eaa7e7825e
					
				
					 3 changed files with 17 additions and 6 deletions
				
			
		|  | @ -196,7 +196,8 @@ def set_filename(self, filename): | ||||||
|                 self.filename_change_hook() |                 self.filename_change_hook() | ||||||
| 
 | 
 | ||||||
|     def open(self, event=None, editFile=None): |     def open(self, event=None, editFile=None): | ||||||
|         if self.editwin.flist: |         flist = self.editwin.flist | ||||||
|  |         if flist: | ||||||
|             if not editFile: |             if not editFile: | ||||||
|                 filename = self.askopenfile() |                 filename = self.askopenfile() | ||||||
|             else: |             else: | ||||||
|  | @ -207,16 +208,22 @@ def open(self, event=None, editFile=None): | ||||||
|                 # we open a new window.  But we won't replace the |                 # we open a new window.  But we won't replace the | ||||||
|                 # shell window (which has an interp(reter) attribute), which |                 # shell window (which has an interp(reter) attribute), which | ||||||
|                 # gets set to "not modified" at every new prompt. |                 # 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: |                 try: | ||||||
|                     interp = self.editwin.interp |                     interp = self.editwin.interp | ||||||
|                 except AttributeError: |                 except AttributeError: | ||||||
|                     interp = None |                     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: |                 else: | ||||||
|                     self.editwin.flist.open(filename) |                     flist.open(filename) | ||||||
|             else: |             else: | ||||||
|  |                 if self.text: | ||||||
|                     self.text.focus_set() |                     self.text.focus_set() | ||||||
|  |              | ||||||
|             return "break" |             return "break" | ||||||
|         # |         # | ||||||
|         # Code for use outside IDLE: |         # Code for use outside IDLE: | ||||||
|  |  | ||||||
|  | @ -1458,6 +1458,7 @@ def main(): | ||||||
|     if tkversionwarning: |     if tkversionwarning: | ||||||
|         shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) |         shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) | ||||||
| 
 | 
 | ||||||
|  |     while flist.inversedict:  # keep IDLE running while files are open. | ||||||
|         root.mainloop() |         root.mainloop() | ||||||
|     root.destroy() |     root.destroy() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -64,6 +64,9 @@ Core and Builtins | ||||||
| Library | 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. | - Issue #14876: Use user-selected font for highlight configuration. | ||||||
|   Patch by Roger Serwy. |   Patch by Roger Serwy. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Terry Jan Reedy
						Terry Jan Reedy