From 5d9e46e46991749b766fb89d70c65f7ddb3cae54 Mon Sep 17 00:00:00 2001
From: culler <culler>
Date: Sun, 13 Jan 2019 16:43:19 +0000
Subject: [PATCH 611/693] Avoid errors when a menu is destroyed before its
 postcommand is run.

---
 library/menu.tcl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/library/menu.tcl b/library/menu.tcl
index cdfcc13f1..8d06868d1 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -493,11 +493,13 @@ proc ::tk::MenuMotion {menu x y state} {
             if {[string is false $mode]} {
                 set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
                 if {[$menu type $index] eq "cascade"} {
+                    # Catch these postcascade commands since the menu could be
+                    # destroyed before they run.
                     set Priv(menuActivatedTimer) \
-                        [after $delay [list $menu postcascade active]]
+                        [after $delay "catch {$menu postcascade active}"]
                 } else {
                     set Priv(menuDeactivatedTimer) \
-                        [after $delay [list $menu postcascade none]]
+                        [after $delay "catch {$menu postcascade none}"]
                 }
             }
         }
-- 
2.19.1

