-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-112898: Fix double close dialog with warning about unsafed files #113513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 15 commits
a0bb7ab
eda5750
3686a65
b305b36
a84a2d7
0ce7d86
ce08ba0
92c1206
4cefbea
bbdee67
ab7800a
63087e3
4c7ad17
4794ee7
8d9a7f0
7ccc8fa
bf6f348
60ccabb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| ## _tk_type and its initializer are private to this section. | ||
|
|
||
| _tk_type = None | ||
| _idle_root = None | ||
|
|
||
| def _init_tk_type(): | ||
| """ Initialize _tk_type for isXyzTk functions. | ||
|
|
@@ -33,17 +34,20 @@ def _init_tk_type(): | |
| _tk_type = "cocoa" | ||
| return | ||
|
|
||
| root = tkinter.Tk() | ||
| ws = root.tk.call('tk', 'windowingsystem') | ||
| else: | ||
| if _idle_root is None: | ||
| _tk_type = "cocoa" | ||
| return | ||
|
Comment on lines
+38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe everything from the 'testing' import to here can be deleted and these 3 lines dedented twice. IDLE will set _idle_root, at least when on mac and if a test on mac needs an accurate _tk_type, it should check requires('gui') and set _idle_root. Checking it here is redundant. Do as you wish for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm leaving this as is for now, I can check later if it is save to remove the testing import. |
||
|
|
||
| ws = _idle_root.tk.call('tk', 'windowingsystem') | ||
| if 'x11' in ws: | ||
| _tk_type = "xquartz" | ||
| elif 'aqua' not in ws: | ||
| _tk_type = "other" | ||
| elif 'AppKit' in root.tk.call('winfo', 'server', '.'): | ||
| elif 'AppKit' in _idle_root.tk.call('winfo', 'server', '.'): | ||
| _tk_type = "cocoa" | ||
| else: | ||
| _tk_type = "carbon" | ||
| root.destroy() | ||
| else: | ||
| _tk_type = "other" | ||
| return | ||
|
|
@@ -216,11 +220,6 @@ def help_dialog(event=None): | |
| root.bind('<<open-config-dialog>>', config_dialog) | ||
| root.createcommand('::tk::mac::ShowPreferences', config_dialog) | ||
| if flist: | ||
| root.bind('<<close-all-windows>>', flist.close_all_callback) | ||
|
|
||
| # The binding above doesn't reliably work on all versions of Tk | ||
| # on macOS. Adding command definition below does seem to do the | ||
| # right thing for now. | ||
| root.createcommand('::tk::mac::Quit', flist.close_all_callback) | ||
|
|
||
| if isCarbonTk(): | ||
|
|
@@ -266,6 +265,8 @@ def setupApp(root, flist): | |
| isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which | ||
| are initialized here as well. | ||
| """ | ||
| global _idle_root | ||
| _idle_root = root | ||
| if isAquaTk(): | ||
| hideTkConsole(root) | ||
| overrideRootMenu(root, flist) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1611,6 +1611,12 @@ def main(): | |
| from idlelib.run import fix_scaling | ||
| fix_scaling(root) | ||
|
|
||
| # start editor and/or shell windows: | ||
|
||
| fixwordbreaks(root) | ||
| fix_x11_paste(root) | ||
| flist = PyShellFileList(root) | ||
| macosx.setupApp(root, flist) | ||
|
|
||
| # set application icon | ||
| icondir = os.path.join(os.path.dirname(__file__), 'Icons') | ||
| if system() == 'Windows': | ||
|
|
@@ -1629,11 +1635,6 @@ def main(): | |
| for iconfile in iconfiles] | ||
| root.wm_iconphoto(True, *icons) | ||
|
|
||
| # start editor and/or shell windows: | ||
| fixwordbreaks(root) | ||
| fix_x11_paste(root) | ||
| flist = PyShellFileList(root) | ||
| macosx.setupApp(root, flist) | ||
|
|
||
| if enable_edit: | ||
| if not (cmd or script): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.