Tk Source Code

View Ticket
Login
Ticket UUID: 3382423
Title: wm forget / manage crash and zombie windows
Type: Bug Version: obsolete: 8.6b1.1
Submitter: auriocus Created on: 2011-07-29 19:59:59
Subsystem: 65. Generic Window Operations Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2012-11-10 11:05:03
Resolution: Fixed Closed By: wordtech
    Closed on: 2012-11-10 04:05:03
Description:
I stumbled across an issue with wm forget/wm manage on Aqua. One of the symptoms also appears on Windows. 
Issue 1:
"wm forget" doesn't work correctly, when the toplevel has never been mapped so far:
package require Tk
toplevel .t
# update
wm forget .t

WIthout the update, on Windows I get a "zombie" frame .t - it is possible to pack anythng inside, but it never updates. If it is undocked using wm manage, the toplevel doesn't repaint. WIth an "update" in between, it works on Windows. Only on X11, it works correctly. On Aqua, it crashes in Tk_WmDeadWindow. 

Issue 2: On Aqua, repeatedly docking/undocking a frame irregularly crashes in Tk_WmDeadWIndow at "wm forget". Code:
package require Tk
toplevel .dock
pack [ttk::label .dock.text -text "This is a toplevel\nwhich can be docked"]
pack [ttk::button .dock.d -text "(un)dock" -command dock]
pack [ttk::label .p -text "Place your \nwindow here"] -side left

set docked false
proc dock {} {
  if {$::docked} {
    pack forget .dock
    wm manage .dock
    set ::docked false
  } else {
    wm forget .dock
    pack .dock -side left
    set ::docked true
  }
}

Tracking this issue with valgrind, I noticed an error message already when a toplevel is created and then mapped to the screen:
Valgrind says, after toplevel .t triggers the mapping:

==29387==  Address 0x11a246818 is 40 bytes inside a block of size 480 alloc'd
   ==29387==    at 0x10001150E: calloc (vg_replace_malloc.c:467)
   ==29387==    by 0x1039DAD1F: CGSNewWindowWithOpaqueShape (in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.   framework/Versions/A/CoreGraphics)
   ==29387==    by 0x1016BAF03: _NSCreateWindowWithOpaqueShape2 (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
   ==29387==    by 0x10164F690: -[NSWindow _commonAwake] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
   ==29387==    by 0x10166D1C8: -[NSWindow _makeKeyRegardlessOfVisibility] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
   ==29387==    by 0x10166D13D: -[NSWindow makeKeyAndOrderFront:] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
   ==29387==    by 0x1010C975E: XMapWindow (tkMacOSXSubwindows.c:153)
   ==29387==    by 0x10103238E: Tk_MapWindow (tkWindow.c:1658)
   ==29387==    by 0x10103B239: MapFrame (tkFrame.c:1782)
   ==29387==    by 0x1000CFC02: TclServiceIdle (in /Users/chris/Programmieren/lib/libtcl8.6.dylib)
   ==29387==    by 0x1000B340A: Tcl_DoOneEvent (in /Users/chris/Programmieren/lib/libtcl8.6.dylib)
   ==29387==    by 0x1010176CB: Tk_MainLoop (tkEvent.c:2131)
   ==29387==


It is strange that Tk_MapWindow calls XMapWindow instead of TkWmMapWindow, because there is the following code:


   if (winPtr->flags & TK_WIN_MANAGED) {
           /*
            * Lots of special processing has to be done for top-level windows.
            * Let tkWm.c handle everything itself.
            */

           TkWmMapWindow(winPtr);
           return;
       }


Can it be, that toplevel does not set TK_WIN_MANAGED correctly?
User Comments: wordtech added on 2012-11-10 11:05:03:

allow_comments - 1

Recent commit by dgp appears to fix this issue. Still some redraw issues with the sample script, but it doesn't crash anymore.