From ad0b169fffb30d54aea311de7fc443fec1cbcb2a Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 11 Jul 2004 22:21:19 +0000 Subject: Users can cause Unix file dialog to vanish early; treat like Cancel [Bug 987169] --- ChangeLog | 5 +++++ library/tkfbox.tcl | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d65b68..db9b113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-07-11 Donal K. Fellows + + * library/tkfbox.tcl (::tk::dialog::file::Create): Watch out for + users destroying the dialog indirectly. [Bug 987169] + 2004-07-07 Donal K. Fellows * doc/canvas.n: Add paragraph to make clearer what is going on diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 2173a0d..45892ef 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -11,7 +11,7 @@ # files by clicking on the file icons or by entering a filename # in the "Filename:" entry. # -# RCS: @(#) $Id: tkfbox.tcl,v 1.41 2003/11/12 00:07:03 hobbs Exp $ +# RCS: @(#) $Id: tkfbox.tcl,v 1.42 2004/07/11 22:21:19 dkf Exp $ # # Copyright (c) 1994-1998 Sun Microsystems, Inc. # @@ -1079,9 +1079,14 @@ static char updir_bits[] = { } # the okBtn is created after the typeMenu so that the keyboard traversal - # is in the right order + # is in the right order, and add binding so that we find out when the + # dialog is destroyed by the user (added here instead of to the overall + # window so no confusion about how much gets called; exactly + # once will do). [Bug 987169] + set data(okBtn) [::tk::AmpWidget button $f2.ok \ -text "[mc "&OK"]" -default active -pady 3] + bind $data(okBtn) [list ::tk::dialog::file::Destroyed $w] set data(cancelBtn) [::tk::AmpWidget button $f2.cancel \ -text "[mc "&Cancel"]" -default normal -pady 3] @@ -1112,9 +1117,9 @@ static char updir_bits[] = { $data(cancelBtn) config -command [list ::tk::dialog::file::CancelCmd $w] bind $w [list tk::ButtonInvoke $data(cancelBtn)] bind $w [list tk::AltKeyInDialog $w %A] + # Set up event handlers specific to File or Directory Dialogs # - if { [string equal $class TkFDialog] } { bind $data(ent) [list ::tk::dialog::file::ActivateEnt $w] $data(okBtn) config -command [list ::tk::dialog::file::OkCmd $w] @@ -1656,6 +1661,16 @@ proc ::tk::dialog::file::CancelCmd {w} { upvar ::tk::dialog::file::[winfo name $w] data variable ::tk::Priv + $data(okBtn) configure {} + set Priv(selectFilePath) "" +} + +# Gets called when user destroys the dialog directly [Bug 987169] +# +proc ::tk::dialog::file::Destroyed {w} { + upvar ::tk::dialog::file::[winfo name $w] data + variable ::tk::Priv + set Priv(selectFilePath) "" } @@ -1777,5 +1792,6 @@ proc ::tk::dialog::file::Done {w {selectFilePath ""}} { } } } + $data(okBtn) configure {} set Priv(selectFilePath) $selectFilePath } -- cgit v0.12