obserience <obserie...@gmail.com> added the comment:

My proposed fix isn't compatible with a lot of current Tkinter using code. It 
was a naive first attempt and breaks existing code and doesn't completely solve 
the problem.

Variables currently retain a reference to the TCL interpreter self._tk and 
aren't linked into the widget tree or otherwise accessible to any cleanup logic.

Existing code:
-may expect the self.tk attribute of destroyed widgets to still be set

Existing code (after calling root.destroy()):
-calls methods like Tk.quit() which runs Tcl commands requiring self.tk to 
still be there
--Idle does this "# (Needed for clean exit on Windows 98)" <--apparently
---is this still the case??
-may call get() and set() on Variable instances (this currently works)


Given this it might be better to track all references to the TCL interpreter in 
a separate data structure and add a Tk.cleanup() method that gets rid of them 
all with documentation indicating all calls after this will fail. Alternate 
implementation of this deallocates the TCL interpreter in the _tkinter.c 
bindings with the same results.

One of the core issues here is that the cause of the crash is asynchronous 
signal handlers installed by the TCL library and necessary for the TCL 
interpreter to run at all. If you can run TCL commands, the crash can still be 
triggered.

###separate issue###
The Tk.Quit() doc is wrong. Current inline docs say that it destroys all 
widgets, which it does not. All it seems to do is cause mainloop to return 
after which mainloop can be called again and the GUI resumes functioning. This 
has caused problems when the main thread doesn't exit since the GUI continues 
to exist but is frozen. (See quit_behavior.py)

----------
Added file: https://bugs.python.org/file48791/quit_behavior.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39093>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to