From 0115b442d416799d1774ca0b8487f5d66f85d067 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 7 May 2023 18:32:29 +0000 Subject: Fix [3414695fff]: tk_getOpenFile, tk_getSaveFile, tk_chooseDir: error when parent destroyed first. --- library/choosedir.tcl | 4 +++- library/tk.tcl | 10 ++++++---- library/tkfbox.tcl | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/choosedir.tcl b/library/choosedir.tcl index 68dd9b0..33a66b1 100644 --- a/library/choosedir.tcl +++ b/library/choosedir.tcl @@ -118,7 +118,9 @@ proc ::tk::dialog::file::chooseDir:: {args} { foreach trace [trace info variable data(selectPath)] { trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1] } - $data(dirMenuBtn) configure -textvariable {} + if {[winfo exists $data(dirMenuBtn)]} { + $data(dirMenuBtn) configure -textvariable {} + } # Return value to user # diff --git a/library/tk.tcl b/library/tk.tcl index 89267d6..e00f073 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -178,10 +178,12 @@ proc ::tk::RestoreFocusGrab {grab focus {destroy destroy}} { catch {focus $oldFocus} grab release $grab - if {$destroy eq "withdraw"} { - wm withdraw $grab - } else { - destroy $grab + if {[winfo exists $grab]} { + if {$destroy eq "withdraw"} { + wm withdraw $grab + } else { + destroy $grab + } } if {[winfo exists $oldGrab] && [winfo ismapped $oldGrab]} { if {$oldStatus eq "global"} { diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 0c3cc0c..f034778 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -226,7 +226,9 @@ proc ::tk::dialog::file:: {type args} { foreach trace [trace info variable data(selectPath)] { trace remove variable data(selectPath) {*}$trace } - $data(dirMenuBtn) configure -textvariable {} + if {[winfo exists $data(dirMenuBtn)]} { + $data(dirMenuBtn) configure -textvariable {} + } return $Priv(selectFilePath) } -- cgit v0.12