From: Harald Oehlmann on
Hello List,
a client reported me the following issue and I want to find out the
reason.
So, the question is, if someone has experience with this issue ?

VC6 self-compiled TCL/Tk 8.5.7 on Windows XP SP2.
Application with dynamic menus with arbitrary characters and quantity.
BWidget 1.9
Code fragment below.

Error behaviour:
Application eats for a long time 100% cpu and stopps with the message
box:
Title: Fatal error in wish
Message: Failed to register menu window class

This application already ran for 6 month without issues.

I found this panic message in the TCL source code in win/tkWinMenu.c
function TkpMenuInit.
It is a TclPanik in windows call RegisterClass.

What I suppose:
- an endless number of menus is created and then it fails with "no
more menus"
- a menu has to many items
- there are invalid characters within the menu title

Do you have any idea or has anybody already seen something similar ?

Thank you in advance,
Harald

--- Code fragment for your pleasure ---
..menu configure -postcommand [namespace code Menu]


proc uitk::Menu {} {
variable StateRun
# > First delete menu
set WiMenu .menu
$WiMenu delete 0 end
# > Add new material command
$WiMenu add command -label [mc MenuItem] -command [namespace code
TabDo]
set lNames [dict keys $StateRun]
set Pos 0
set MenuCount [llength $lNames]
if { 0 < $MenuCount } {
$WiMenu add separator
}
foreach Name $lNames {
#
----------------------------------------------------------------------
set lCmd [concat [namespace code TabDo] [list $Name $Pos]]
#
----------------------------------------------------------------------
set WiMenuSub $WiMenu.s$Pos
if {[winfo exists $WiMenuSub]} {
$WiMenuSub delete 0 end
} else {
menu $WiMenuSub -tearoff 0
}
#
----------------------------------------------------------------------
# > Edit, Copy, Delete
foreach OpCur {Edit NewFrom Delete} {
$WiMenuSub add command\
-label [mc MenuItemTab$OpCur]\
-command [concat $lCmd [list $OpCur]]
}
#
----------------------------------------------------------------------
# > Separator to positional entries
if {$MenuCount > 1} {
$WiMenuSub add separator
}
#
----------------------------------------------------------------------
# > Move Top
foreach {OpCur Criterion} {\
Top {$Pos > 1}\
Up {$Pos > 0}\
Down {$Pos < $MenuCount - 1}\
Last {$Pos < $MenuCount - 2}\
} {
if {[expr $Criterion]} {
$WiMenuSub add command\
-label [mc MenuItemTab$OpCur]\
-command [concat $lCmd $OpCur]
}
}
#
----------------------------------------------------------------------
$WiMenu add cascade\
-label [mc MenuItem${Index}Change\
$Name\
[lindex [dict get $StateRun($Index) $Name] $DescPos]]\
-menu $WiMenuSub
#
----------------------------------------------------------------------
incr Pos
}
}