Final Cleanup

When a widget is destroyed, you need to free up any resources it has allocated. The resources associated with attributes are cleaned up by Tk_FreeOptions. The others you must take care of yourself. The ClockDestroy procedure is called as a result of the Tk_EventuallyFree call in the ClockEventProc. The Tk_EventuallyFree procedure is part of a protocol that is needed for widgets that might get deleted when in the middle of processing. Typically the Tk_Preserve and Tk_Release procedures are called at the beginning and end of the widget instance command to mark the widget as being in use. Tk_EventuallyFree will wait until Tk_Release ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.