Tk Source Code

View Ticket
Login
Ticket UUID: 1962404
Title: "exit handlers were created during Tcl_Finalize" error
Type: Bug Version: obsolete: 8.4.19
Submitter: jkbonfield Created on: 2008-05-12 14:00:11
Subsystem: 08. [(label)frame] and [toplevel] Assigned To: pspjuth
Priority: 5 Medium Severity:
Status: Open Last Modified: 2008-05-12 14:00:11
Resolution: None Closed By:
    Closed on:
Description:
DestroyNotify events on frames call TkSetWindowMenuBar to configure the menu for thr frame, which in turn registers for notice of program exit. Unfortunately if the window is being destroyed due to program exit then this causes the Tcl_Finalize function to abort() with a "exit handlers were created during Tcl_Finalize" message.

The following example demonstrates it:

wm protocol . WM_DELETE_WINDOW "exit"
. configure -menu .m

A workaround is to reset the frame menus before exiting. Eg:

wm protocol . WM_DELETE_WINDOW "shutdown"
. configure -menu .m

proc shutdown {} {
    . configure -menu {}
    exit
}

This only happens when WM_DELETE_WINDOW is used on a window configured to have a menu, but I'm not entirely sure why.

Commenting out the TkSetWindowMenuBar call cures the problem. Ie:

*** tkFrame.c~  Sun Apr 29 03:24:02 2007
--- tkFrame.c   Mon May 12 14:57:26 2008
***************
*** 1627,1634 ****
        goto redraw;
      } else if (eventPtr->type == DestroyNotify) {
        if (framePtr->menuName != NULL) {
-           TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
-                   framePtr->menuName, NULL);
            ckfree(framePtr->menuName);
            framePtr->menuName = NULL;
        }
--- 1627,1632 ----

I'm unsure of the impact of this change though. I cannot see why we'd ever want to reconfigure the menu bar of a window that is about to be destroyed, but that most likely means I'm missing something here.

James