Menu

#1274 destroying menubuttons leaves them unpostable

open
6
2006-03-31
2002-08-29
Anonymous
No

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.)

Discussion

  • Todd Helfter

    Todd Helfter - 2002-12-18
    • assigned_to: tmh --> welch
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-01-28
    • assigned_to: welch --> hobbs
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-03-31
    • priority: 5 --> 6
    • summary: Crash destroying menubuttons --> destroying menubuttons leaves them unpostable
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-03-31

    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.

     
MongoDB Logo MongoDB