Tk Source Code

View Ticket
Login
Ticket UUID: 601954
Title: destroying menubuttons leaves them unpostable
Type: Bug Version: None
Submitter: nobody Created on: 2002-08-29 16:12:28
Subsystem: 10. Generic Menus Assigned To: hobbs
Priority: 6 Severity:
Status: Open Last Modified: 2006-03-31 15:13:51
Resolution: None Closed By:
    Closed on:
Description:
I had the following behavior reported to me, which I have 
verified on my machine.

Code to reproduce bug:

#################
proc create {} {
menubutton .mb -text Sample -relief raised -
menu .mb.menu
pack .mb
set m [menu .mb.menu -tearoff 0]
$m add radio -label One -command {}
$m add radio -label Two -command {}
}

create
after 10000 {destroy .mb; create}
#################

As reported by the other user:

"The problem occurs if the menu is still posted when the 
menubutton is destroyed (i.e. no selection was made, or 
the user did not click outside the window).  Under these 
circumstance, if the menubutton is then recreated, the 
menu is no longer dislayed properly (sometimes it won't 
display at all).  I have tried "unpost"ing the menu before 
destroying the menubutton but this doesn't seem to 
have any effect.

The version of tcl/tk I'm using is 8.4 and the platform is 
Solaris. Try clicking on the menu button when it comes 
up and waiting until the program destroys it -- then try to 
open the menu again.  After some time and multiple 
clicks the menu usually reappears -- but this behavior is 
inconsistant and I would like it to be dismissed properly."

I observed the same behavior on a Linux system 
(specifically Linux 2.4.8-26mdk) with the KDE window 
manager (other window managers not tried). I duplicated 
the behavior using Tcl/Tk 8.3.4 and 8.4b2.

The same code was able to crash wish (both 8.3.2 and 
8.4b2) on Windows 2000. If the menu is posted but no 
items are active (the mouse isn't over the menu), there's 
no problem; it's as if nothing happened, and the 
menubutton and menu still work fine. However, if there is 
an active item (the mouse is over an item), the 
destroy/create seems to occur, but then as soon as I 
move my mouse, wish crashes.

(I'll admit that what the user was doing isn't great 
programming practice. But wish shouldn't crash as a 
result.)
User Comments: hobbs added on 2006-03-31 15:13:51:
Logged In: YES 
user_id=72656

the work-around for this is to do 'set ::tk::Priv(postedMb)
""' if you are destroying the current menubutton.  I can't
crash wish on Windows with this in 8.4, but the unix side is
reproducable as an issue.