[Patches] [ python-Patches-1121234 ] Reference count bug fix

SourceForge.net noreply at sourceforge.net
Sun Feb 27 20:27:19 CET 2005


Patches item #1121234, was opened at 2005-02-12 07:02
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1121234&group_id=5470

Category: Tkinter
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michiel de Hoon (mdehoon)
Assigned to: Martin v. Löwis (loewis)
Summary: Reference count bug fix

Initial Comment:
In the _loadtk method of the class Tk, there are two
calls self.tk.createcommand, one for 'tkerror' and one
for 'exit'. In the createcommand function in
_tkinter.c, there is a Py_XINCREF for the Tk widget and
one for the Python function (_tkerror or _exit). The
corresponding Py_XDECREFs are called (via
Tkapp_DeleteCommand) in PythonCmdDelete. The
Tkapp_DeleteCommand is called by the deletecommand in
the destroy method of class Misc in Tkinter.py.
However, the deletecommand is called only for commands
listed in self._tclCommands. Now, if a command is
created via the _register method in class Misc, the
command is appended to self._tclCommands. However, the
'tkerror' and 'exit' commands, created in the _loadtk
method of the class Tk, are not appended to
self._tclCommands. Hence, the '_tkerror' and '_exit'
functions as well as the Tk widget itself have an
incorrect reference count. The Tkapp_Dealloc routine in
_tkinter.c is not called and the Tk widget is not
destroyed.
The attached patch simply adds a
self._tclCommands.append for 'tkerror' and 'exit'. With
this patch, a Tk widget is destroyed and Tkapp_Dealloc
is called correctly.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-02-27 20:27

Message:
Logged In: YES 
user_id=21627

Wouldn't it be better to use _register for _tkerror and
_exit as well? This patch overwrites self._tclCommands, but
the object may already have a _tclCommands attribute.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1121234&group_id=5470


More information about the Patches mailing list