Bug in tk_getSaveFile on UNIX 
Author Message
 Bug in tk_getSaveFile on UNIX

Well, this is actually not in tk_getSaveFile, but the error occurs when
it is called.  Whenever tk_getSaveFile must popup a dialog (confirm
overwrite a file, or file not writable, etc), it has a parent of . even
if tk_getSaveFile had another toplevel specified as it's parent.

ie:
% toplevel .t
.t
% wm iconify .
% tk_getSaveFile -parent .t

Select a file that exists, and the warning dialog will pop up over . not
.t
This behavior occurs on Tk 4.2 and 8.0 on Unix.  Does anyone have a
patch for this?

-Dan Curtiss
GE-Harris Railway Electronics
http://www.*-*-*.com/



Fri, 17 Mar 2000 03:00:00 GMT  
 Bug in tk_getSaveFile on UNIX

Quote:

> Well, this is actually not in tk_getSaveFile, but the error occurs when
> it is called.  Whenever tk_getSaveFile must popup a dialog (confirm
> overwrite a file, or file not writable, etc), it has a parent of . even
> if tk_getSaveFile had another toplevel specified as it's parent.

> ie:
> % toplevel .t
> .t
> % wm iconify .
> % tk_getSaveFile -parent .t

> Select a file that exists, and the warning dialog will pop up over . not
> .t
> This behavior occurs on Tk 4.2 and 8.0 on Unix.  Does anyone have a
> patch for this?

> -Dan Curtiss
> GE-Harris Railway Electronics
> http://www.*-*-*.com/

Dan,

Yeah, this is a bug.  In fact, the -parent was getting ignored
altogether, so no matter which screen you posted the tk_getSaveFile
from, it would always show up on the screen of ".".

Here is a patch, I think it works, but I haven't rigorously tested it,
or checked it back into the source tree.  If you are interested, it
would be great if you would apply the patch (in lib/tk8.0), and give
it a spin, and tell me if I killed anything in the process of fixing
this one bug.

Jim.

+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===

SunScript

+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===
*** tkfbox.tcl_old      Wed Oct  1 15:10:04 1997
--- tkfbox.tcl  Wed Oct  1 14:51:04 1997
***************
*** 11,17 ****
  #     files by clicking on the file icons or by entering a filename
  #     in the "Filename:" entry.
  #

  #
  # Copyright (c) 1994-1996 Sun Microsystems, Inc.
  #
--- 11,17 ----
  #     files by clicking on the file icons or by entering a filename
  #     in the "Filename:" entry.
  #

  #
  # Copyright (c) 1994-1996 Sun Microsystems, Inc.
  #
***************
*** 630,636 ****
  #
  proc tkFDialog {args} {
      global tkPriv
!     set w .__tk_filedialog
      upvar #0 $w data

      if ![string compare [lindex [info level 0] 0] tk_getOpenFile] {
--- 630,636 ----
  #
  proc tkFDialog {args} {
      global tkPriv
!     set w __tk_filedialog
      upvar #0 $w data

      if ![string compare [lindex [info level 0] 0] tk_getOpenFile] {
***************
*** 641,646 ****
--- 641,652 ----

      tkFDialog_Config $w $type $args

+     if {![string compare $data(-parent) .]} {
+         set w .$w
+     } else {
+         set w $data(-parent).$w
+     }
+
      # (re)create the dialog box if necessary
      #
      if {![winfo exists $w]} {
***************
*** 783,789 ****
  }

  proc tkFDialog_Create {w} {
!     upvar #0 $w data
      global tk_library

      toplevel $w -class TkFDialog
--- 789,796 ----
  }

  proc tkFDialog_Create {w} {
!     set dataName [lindex [split $w .] end]
!     upvar #0 $dataName data
      global tk_library

      toplevel $w -class TkFDialog
***************
*** 793,799 ****
      set f1 [frame $w.f1]
      label $f1.lab -text "Directory:" -under 0
      set data(dirMenuBtn) $f1.menu
!     set data(dirMenu) [tk_optionMenu $f1.menu [format %s(selectPath) $w] ""]
      set data(upBtn) [button $f1.up]
      if ![info exists tkPriv(updirImage)] {
        set tkPriv(updirImage) [image create bitmap -data {
--- 800,806 ----
      set f1 [frame $w.f1]
      label $f1.lab -text "Directory:" -under 0
      set data(dirMenuBtn) $f1.menu
!     set data(dirMenu) [tk_optionMenu $f1.menu [format %s(selectPath) $dataName] ""]
      set data(upBtn) [button $f1.up]
      if ![info exists tkPriv(updirImage)] {
        set tkPriv(updirImage) [image create bitmap -data {
***************
*** 920,926 ****
  #     due to multiple concurrent events.
  #
  proc tkFDialog_UpdateWhenIdle {w} {
!     upvar #0 $w data

      if [info exists data(updateId)] {
        return
--- 927,933 ----
  #     due to multiple concurrent events.
  #
  proc tkFDialog_UpdateWhenIdle {w} {
!     upvar #0 [winfo name $w] data

      if [info exists data(updateId)] {
        return
***************
*** 936,942 ****
  #     directories.
  #
  proc tkFDialog_Update {w} {
!     upvar #0 $w data
      global tk_library tkPriv

      # This proc may be called within an idle handler. Make sure that the
--- 943,950 ----
  #     directories.
  #
  proc tkFDialog_Update {w} {
!     set dataName [winfo name $w]
!     upvar #0 $dataName data
      global tk_library tkPriv

      # This proc may be called within an idle handler. Make sure that the
***************
*** 967,973 ****
        # should have been checked before tkFDialog_Update is called, so
        # we normally won't come to here. Anyways, give an error and abort
        # action.
!       tk_messageBox -type ok -message \
            "Cannot change to the directory \"$data(selectPath)\".\nPermission denied."\
            -icon warning
        cd $appPWD
--- 975,981 ----
        # should have been checked before tkFDialog_Update is called, so
        # we normally won't come to here. Anyways, give an error and abort
        # action.
!       tk_messageBox -type ok -parent $data(-parent) -message \
            "Cannot change to the directory \"$data(selectPath)\".\nPermission denied."\
            -icon warning
        cd $appPWD
***************
*** 1033,1039 ****
      }

      $data(dirMenu) delete 0 end
!     set var [format %s(selectPath) $w]
      foreach path $list {
        $data(dirMenu) add command -label $path -command [list set $var $path]
      }
--- 1041,1047 ----
      }

      $data(dirMenu) delete 0 end
!     set var [format %s(selectPath) $dataName]
      foreach path $list {
        $data(dirMenu) add command -label $path -command [list set $var $path]
      }
***************
*** 1053,1059 ****
  #     Sets data(selectPath) without invoking the trace procedure
  #
  proc tkFDialog_SetPathSilently {w path} {
!     upvar #0 $w data

      trace vdelete  data(selectPath) w "tkFDialog_SetPath $w"
      set data(selectPath) $path
--- 1061,1067 ----
  #     Sets data(selectPath) without invoking the trace procedure
  #
  proc tkFDialog_SetPathSilently {w path} {
!     upvar #0 [winfo name $w] data

      trace vdelete  data(selectPath) w "tkFDialog_SetPath $w"
      set data(selectPath) $path
***************
*** 1064,1071 ****
  # This proc gets called whenever data(selectPath) is set
  #
  proc tkFDialog_SetPath {w name1 name2 op} {
!     upvar #0 $w data
!
      tkFDialog_UpdateWhenIdle $w
  }

--- 1072,1078 ----
  # This proc gets called whenever data(selectPath) is set
  #
  proc tkFDialog_SetPath {w name1 name2 op} {
!     upvar #0 [winfo name $w] data
      tkFDialog_UpdateWhenIdle $w
  }

***************
*** 1072,1078 ****
  # This proc gets called whenever data(filter) is set
  #
  proc tkFDialog_SetFilter {w type} {
!     upvar #0 $w data
      upvar \#0 $data(icons) icons

      set data(filter) [lindex $type 1]
--- 1079,1085 ----
  # This proc gets called whenever data(filter) is set
  #
  proc tkFDialog_SetFilter {w type} {
!     upvar #0 [winfo name $w] data
      upvar \#0 $data(icons) icons

      set data(filter) [lindex $type 1]
***************
*** 1192,1198 ****
  # entry box is the selection.
  #
  proc tkFDialog_EntFocusIn {w} {
!     upvar #0 $w data

      if [string compare [$data(ent) get] ""] {
        $data(ent) selection from 0
--- 1199,1205 ----
  # entry box is the selection.
  #
  proc tkFDialog_EntFocusIn {w} {
!     upvar #0 [winfo name $w] data

      if [string compare [$data(ent) get] ""] {
        $data(ent) selection from 0
***************
*** 1212,1218 ****
  }

  proc tkFDialog_EntFocusOut {w} {
!     upvar #0 $w data

      $data(ent) selection clear
  }
--- 1219,1225 ----
  }

  proc tkFDialog_EntFocusOut {w} {
!     upvar #0 [winfo name $w] data

      $data(ent) selection clear
  }
***************
*** 1221,1227 ****
  # Gets called when user presses Return in the "File name" entry.
  #
  proc tkFDialog_Activa{*filter*}t {w} {
!     upvar #0 $w data

      set text [string trim [$data(ent) get]]
      set list [tkFDialogResolveFile $data(selectPath) $text \
--- 1228,1234 ----
  # Gets called when user presses Return in the "File name" entry.
  #
  proc tkFDialog_Activa{*filter*}t {w} {
!     upvar #0 [winfo name $w] data

      set text [string trim [$data(ent) get]]
      set list [tkFDialogResolveFile $data(selectPath) $text \
***************
*** 1248,1254 ****
        }
        FILE {
            if ![string compare $data(type) open] {
!               tk_messageBox -icon warning -type ok \
                    -message "File \"[file join $path $file]\" does not exist."
                $data(ent) select from 0
                $data(ent) select to   end
--- 1255,1261 ----
        }
        FILE {
            if ![string compare $data(type) open] {
!               tk_messageBox -icon warning -type ok -parent $data(-parent) \
                    -message "File \"[file join $path $file]\" does not exist."
                $data(ent) select from 0
                $data(ent) select to   end
***************
*** 1260,1266 ****
            }
        }
        PATH {
!           tk_messageBox -icon warning -type ok \
                -message "Directory \"$path\" does not exist."
            $data(ent) select from 0
            $data(ent) select to   end
--- 1267,1273 ----
            }
        }
        PATH {
!           tk_messageBox -icon warning -type ok -parent $data(-parent) \
                -message "Directory \"$path\" does not exist."
            $data(ent) select from 0
            $data(ent) select to   end
***************
*** 1267,1273 ****
            $data(ent) icursor end
        }
        CHDIR {
!           tk_messageBox -type ok -message \
               "Cannot change to the directory \"$path\".\nPermission denied."\
                -icon warning
            $data(ent) select from 0
--- 1274,1280 ----
            $data(ent) icursor end
        }
        CHDIR {
!           tk_messageBox -type ok -parent $data(-parent) -message \
               "Cannot change to the directory \"$path\".\nPermission denied."\
                -icon warning
            $data(ent) select from 0
***************
*** 1275,1281 ****
            $data(ent) icursor end
        }
        ERROR {
!           tk_messageBox -type ok -message \
               "Invalid file name \"$path\"."\
                -icon warning
            $data(ent) select from 0
--- ...

read more »



Sun, 19 Mar 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TIP #67: Allow Subclassing of tk_getOpenFile, tk_getSaveFile on UNIX

2. BUG: tk_getSaveFile on Tcl 8.x

3. BUG in tk_getSaveFile and tk_getOpenFile

4. bug with tk_getOpenFile/tk_getSaveFile

5. BUG: tk_getOpenFile/tk_getSaveFile

6. BUG in tk_GetOpenFile / tk_getSaveFile

7. Bug: tk_getSaveFile ?

8. BUG: tk_getSaveFile on Solaris2.5/tk4.2

9. Bug Report: tk_getSaveFile in Tk 4.2

10. BUGS, BUGS, BUGS, BUGS, C4 BUGS

11. UNIX man (was: Re: socket bug)

12. bug in interrupting xscheme read (for unix)

 

 
Powered by phpBB® Forum Software